Skip to content

Commit e018443

Browse files
committed
test: Add tests for forwards & backwards nav
1 parent f747478 commit e018443

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

873901
const MODE_HYDRATE = 1 << 5;

0 commit comments

Comments
 (0)