Skip to content

Commit c68ff03

Browse files
committed
test: Add tests for forwards & backwards nav
1 parent 16a7e61 commit c68ff03

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

872900
const MODE_HYDRATE = 1 << 5;

0 commit comments

Comments
 (0)