Add testcase - depth-7-nested-2 as a more nested case

This commit is contained in:
2019-07-21 09:18:16 +05:30
parent 70a782ad0f
commit 7ce8ee1778
2 changed files with 51 additions and 8 deletions
+18 -8
View File
@@ -7,6 +7,7 @@ import { traverse } from "../src";
import { mountAndGetRootNode } from "./utils/mount-in-enzyme";
import CDepth2Nested1 from "./sample-components/depth-2-nested-1";
import CDepth3Nested1 from "./sample-components/depth-3-nested-1";
import CDepth7Nested2 from "./sample-components/depth-7-nested-2";
describe("traverse", () => {
let container: HTMLDivElement;
@@ -28,16 +29,25 @@ describe("traverse", () => {
expect(mockCallback.mock.calls.length).toBe(2);
});
});
it("should work for depth=3 with level of nesting=1", () => {
const rootNode = mountAndGetRootNode(CDepth3Nested1, container);
const mockCallback = jest.fn();
it("should work for depth=3 with level of nesting=1", () => {
const rootNode = mountAndGetRootNode(CDepth3Nested1, container);
const mockCallback = jest.fn();
traverse(rootNode, mockCallback);
traverse(rootNode, mockCallback);
// Shouldn't count just component depth, should include string nodes
expect(mockCallback.mock.calls.length).not.toBe(2);
expect(mockCallback.mock.calls.length).toBe(3);
// Shouldn't count just component depth, should include string nodes
expect(mockCallback.mock.calls.length).not.toBe(2);
expect(mockCallback.mock.calls.length).toBe(3);
});
it("should work for depth=7 with level of nesting=2", () => {
const rootNode = mountAndGetRootNode(CDepth7Nested2, container);
const mockCallback = jest.fn();
traverse(rootNode, mockCallback);
expect(mockCallback.mock.calls.length).toBe(7);
});
});
});