Skip to content

Commit 4a823d7

Browse files
committed
test: Add tests for forwards & backwards nav
1 parent 9897485 commit 4a823d7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/router.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,34 @@ describe('Router', () => {
946946
expect(scratch).to.have.property('textContent', 'data');
947947
});
948948

949+
it('should support navigating backwards and forwards', async () => {
950+
render(
951+
<LocationProvider>
952+
<Router>
953+
<Route path="/" component={() => null} />
954+
<Route path="/foo" component={() => null} />
955+
</Router>
956+
<ShallowLocation />
957+
</LocationProvider>,
958+
scratch
959+
);
960+
961+
navigation.navigate('/foo');
962+
await sleep(10);
963+
964+
expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} });
965+
966+
navigation.back();
967+
await sleep(10);
968+
969+
expect(loc).to.deep.include({ url: '/', path: '/', searchParams: {} });
970+
971+
navigation.forward();
972+
await sleep(10);
973+
974+
expect(loc).to.deep.include({ url: '/foo', path: '/foo', searchParams: {} });
975+
});
976+
949977
it('should intercept clicks on links inside open shadow DOM', async () => {
950978
const shadowlink = document.createElement('a');
951979
shadowlink.href = '/shadow';

0 commit comments

Comments
 (0)