Skip to content

Commit 8b54b85

Browse files
authored
Update match.test.js
1 parent 481b46f commit 8b54b85

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/match.test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ function doExec(path, route, opts) {
77
describe('match', () => {
88
it('Base route', () => {
99
const accurateResult = doExec('/', '/');
10-
expect(accurateResult).toEqual({ path: '/', params: {} });
10+
expect(accurateResult).toEqual({ path: '/', params: {}, query: {} });
1111

1212
const inaccurateResult = doExec('/user/1', '/');
1313
expect(inaccurateResult).toEqual(undefined);
1414
});
1515

1616
it('Param route', () => {
1717
const accurateResult = doExec('/user/2', '/user/:id');
18-
expect(accurateResult).toEqual({ path: '/', params: { id: '2' } });
18+
expect(accurateResult).toEqual({ path: '/', params: { id: '2' }, query: {} });
1919

2020
const inaccurateResult = doExec('/', '/user/:id');
2121
expect(inaccurateResult).toEqual(undefined);
2222
});
2323

2424
it('Optional param route', () => {
2525
const accurateResult = doExec('/user', '/user/:id?');
26-
expect(accurateResult).toEqual({ path: '/', params: { id: undefined } });
26+
expect(accurateResult).toEqual({ path: '/', params: { id: undefined }, query: {} });
2727

2828
const inaccurateResult = doExec('/', '/user/:id?');
2929
expect(inaccurateResult).toEqual(undefined);
@@ -35,15 +35,18 @@ describe('match', () => {
3535
params: {
3636
seg1: '_SEGMENT1_',
3737
seg2: '_SEGMENT2_'
38-
}
38+
},
39+
path: '/about-late/_SEGMENT1_/_SEGMENT2_/',
40+
query: {}
3941
});
4042
});
4143

4244
it('should not overwrite existing properties', () => {
4345
const result = doExec('/foo/bar', '/:path/:query');
4446
expect(result).toEqual({
4547
params: { path: 'foo', query: 'bar' },
46-
path: '/'
48+
path: '/foo/bar',
49+
query: {}
4750
});
4851
});
4952
});

0 commit comments

Comments
 (0)