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 24, 2024
1 parent a1745ac commit 1fe771e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,5 +1425,64 @@ describe('useTravel', () => {
],
}
`);

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

expect(nextState).toEqual(8);
expect(controls.position).toEqual(3);
expect(controls.getHistory()).toEqual([3, 4, 5, 8]);
expect(controls.canBack()).toBe(true);
expect(controls.canForward()).toBe(false);
expect(controls.patches).toMatchInlineSnapshot(`
{
"inversePatches": [
[
{
"op": "replace",
"path": [],
"value": 3,
},
],
[
{
"op": "replace",
"path": [],
"value": 4,
},
],
[
{
"op": "replace",
"path": [],
"value": 5,
},
],
],
"patches": [
[
{
"op": "replace",
"path": [],
"value": 4,
},
],
[
{
"op": "replace",
"path": [],
"value": 5,
},
],
[
{
"op": "replace",
"path": [],
"value": 8,
},
],
],
}
`);
});
});

0 comments on commit 1fe771e

Please sign in to comment.