@@ -4,7 +4,8 @@ import { createMatcher } from '../../../src/create-matcher'
4
4
const routes = [
5
5
{ path : '/' , name : 'home' , component : { name : 'home' } } ,
6
6
{ path : '/foo' , name : 'foo' , component : { name : 'foo' } } ,
7
- { path : '*' , props : true , component : { name : 'notFound' } }
7
+ { path : '/baz/:testparam' , name : 'baz' , component : { name : 'baz' } } ,
8
+ { path : '*' , props : true , name : 'notFound' , component : { name : 'notFound' } }
8
9
]
9
10
10
11
describe ( 'Creating Matcher' , function ( ) {
@@ -26,14 +27,29 @@ describe('Creating Matcher', function () {
26
27
expect ( matched . length ) . toBe ( 0 )
27
28
expect ( name ) . toBe ( 'bar' )
28
29
expect ( console . warn ) . toHaveBeenCalled ( )
29
- expect ( console . warn . calls . argsFor ( 0 ) [ 0 ] ) . toMatch ( ' Route with name \ 'bar\ ' does not exist' )
30
+ expect ( console . warn . calls . argsFor ( 0 ) [ 0 ] ) . toMatch ( " Route with name 'bar' does not exist" )
30
31
} )
31
32
32
33
it ( 'in production, it has not logged this warning' , function ( ) {
33
34
match ( { name : 'foo' } , routes [ 0 ] )
34
35
expect ( console . warn ) . not . toHaveBeenCalled ( )
35
36
} )
36
37
38
+ it ( 'matches named route with params without warning' , function ( ) {
39
+ process . env . NODE_ENV = 'development'
40
+ const { name, path } = match ( { name : 'baz' , params : { testparam : 'testvalue' } } )
41
+ expect ( console . warn ) . not . toHaveBeenCalled ( )
42
+ expect ( name ) . toEqual ( 'baz' )
43
+ expect ( path ) . toEqual ( '/baz/testvalue' )
44
+ } )
45
+
46
+ it ( 'matches asterisk routes with a default param name without warning' , function ( ) {
47
+ process . env . NODE_ENV = 'development'
48
+ const { params } = match ( { name : 'notfound' , params : { pathMatch : '/not-found' } } , routes [ 0 ] )
49
+ expect ( console . warn ) . not . toHaveBeenCalled ( )
50
+ expect ( params ) . toEqual ( { pathMatch : '/not-found' } )
51
+ } )
52
+
37
53
it ( 'matches asterisk routes with a default param name' , function ( ) {
38
54
const { params } = match ( { path : '/not-found' } , routes [ 0 ] )
39
55
expect ( params ) . toEqual ( { pathMatch : '/not-found' } )
0 commit comments