Skip to content

Commit

Permalink
test(case): add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Mar 23, 2024
1 parent 15d3003 commit efaaaf8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ describe('useTravel', () => {
expect(controls.getHistory()).toEqual([3, 4, 5, 6]);
expect(controls.canBack()).toBe(true);
expect(controls.canForward()).toBe(false);
(global as any).x = true;

act(() => controls.back());
[nextState, setState, controls] = result.current;
expect(nextState).toEqual(5);
Expand Down Expand Up @@ -1196,5 +1196,14 @@ describe('useTravel', () => {
expect(controls.getHistory()).toEqual([3, 4, 5, 6]);
expect(controls.canBack()).toBe(true);
expect(controls.canForward()).toBe(true);

act(() => setState(() => 7));
[nextState, setState, controls] = result.current;

expect(nextState).toEqual(7);
expect(controls.position).toEqual(3);
expect(controls.getHistory()).toEqual([3, 4, 5, 7]);
expect(controls.canBack()).toBe(true);
expect(controls.canForward()).toBe(false);
});
});

0 comments on commit efaaaf8

Please sign in to comment.