Skip to content

Commit 4b99ec5

Browse files
committed
test: Add tests for forwards & backwards nav
1 parent 57eec3e commit 4b99ec5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/router.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,34 @@ describe('Router', () => {
869869
const secondLast = new URL(entries[entries.length - 2].url);
870870
expect(secondLast.pathname).to.equal('/');
871871
});
872+
873+
it('should support navigating backwards and forwards', async () => {
874+
render(
875+
<LocationProvider>
876+
<Router>
877+
<Route path="/" component={() => null} />
878+
<Route path="/foo" component={() => null} />
879+
</Router>
880+
<ShallowLocation />
881+
</LocationProvider>,
882+
scratch
883+
);
884+
885+
navigation.navigate('/foo');
886+
await sleep(10);
887+
888+
expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} });
889+
890+
navigation.back();
891+
await sleep(10);
892+
893+
expect(loc).to.deep.include({ url: '/', path: '/', searchParams: {} });
894+
895+
navigation.forward();
896+
await sleep(10);
897+
898+
expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} });
899+
});
872900
});
873901

874902
const MODE_HYDRATE = 1 << 5;

0 commit comments

Comments
 (0)