Skip to content

Commit

Permalink
change jock mock time method
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranps committed Feb 23, 2019
1 parent 8e67ab9 commit 861bc57
Show file tree
Hide file tree
Showing 3 changed files with 936 additions and 214 deletions.
30 changes: 20 additions & 10 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,29 @@ it("should match with snapshot", () => {
expect(component).toMatchSnapshot();
});

it("should render Tree diagram", () => {
it("should render Tree Chart", () => {
const component = mount(<App />);
expect(component.find("Tree").length).toEqual(1);
expect(component.find("TreeChart").length).toEqual(1);
});

it("should render Seven Circles", () => {
const component = mount(<App />);
expect(component.find("Circle").length).toEqual(7);
});

it("should render Six Paths", () => {
const component = mount(<App />);
expect(component.find("Path").length).toEqual(6);
});

it("should animate the tree in inorder", () => {
const inorder = ["12", "23", "16", "4", "9", "34", "92"];
const component = mount(<App />);
component.find("Select").simulate("change", { target: { value: "inorder" } });
component.find("Button").simulate("click");
jest.runAllTimers();
component.update();
inorder.forEach((x, i) => {
jest.advanceTimersByTime(1500);
component.update();
expect(
component
.find("Item")
Expand All @@ -45,9 +55,9 @@ it("should animate tree in postorder", () => {
.find("Select")
.simulate("change", { target: { value: "postorder" } });
component.find("Button").simulate("click");
jest.runAllTimers();
component.update();
postorder.forEach((x, i) => {
jest.advanceTimersByTime(1500);
component.update();
expect(
component
.find("Item")
Expand All @@ -64,9 +74,9 @@ it("should animate tree in preorder", () => {
.find("Select")
.simulate("change", { target: { value: "preorder" } });
component.find("Button").simulate("click");
jest.runAllTimers();
component.update();
preorder.forEach((x, i) => {
jest.advanceTimersByTime(1500);
component.update();
expect(
component
.find("Item")
Expand All @@ -81,9 +91,9 @@ it("should animate tree in bft", () => {
const component = mount(<App />);
component.find("Select").simulate("change", { target: { value: "bft" } });
component.find("Button").simulate("click");
jest.runAllTimers();
component.update();
bft.forEach((x, i) => {
jest.advanceTimersByTime(1500);
component.update();
expect(
component
.find("Item")
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class App extends Component {
this.traversal = setTimeout(() => {
this.setState({ tree: [...this.state.tree, arr[0]] });
this.animateTraversal(arr.slice(1));
}, 1000);
}, 1500);
}
};

Expand Down
Loading

0 comments on commit 861bc57

Please sign in to comment.