2
2
import { createMatcher } from '../../../src/create-matcher'
3
3
4
4
const routes = [
5
- { path : '/' , name : 'home' , component : { name : 'home' } } ,
6
- { path : '/foo' , name : 'foo' , component : { name : 'foo' } } ,
5
+ { path : '/' , name : 'home' , component : { name : 'home' } } ,
6
+ { path : '/foo' , name : 'foo' , component : { name : 'foo' } } ,
7
7
]
8
8
9
9
describe ( 'Creating Matcher' , function ( ) {
@@ -21,15 +21,15 @@ describe('Creating Matcher', function () {
21
21
22
22
it ( 'in development, has logged a warning if a named route does not exist' , function ( ) {
23
23
process . env . NODE_ENV = 'development'
24
- expect ( ( ) => {
25
- match ( { name : 'bar' } , routes [ 0 ] ) ;
26
- } ) . toThrow ( new TypeError ( 'Cannot read property \'regex\' of undefined' ) ) ;
24
+ const { name , matched } = match ( { name : 'bar' } , routes [ 0 ] )
25
+ expect ( matched . length ) . toBe ( 0 )
26
+ expect ( name ) . toBe ( 'bar' )
27
27
expect ( console . warn ) . toHaveBeenCalled ( )
28
- expect ( console . warn . calls . argsFor ( 0 ) [ 0 ] ) . toMatch ( 'Route with name \'bar\' does not exist' ) ;
28
+ expect ( console . warn . calls . argsFor ( 0 ) [ 0 ] ) . toMatch ( 'Route with name \'bar\' does not exist' )
29
29
} )
30
30
31
31
it ( 'in production, it has not logged this warning' , function ( ) {
32
- match ( { name : 'foo' } , routes [ 0 ] ) ;
32
+ match ( { name : 'foo' } , routes [ 0 ] )
33
33
expect ( console . warn ) . not . toHaveBeenCalled ( )
34
34
} )
35
35
} )
0 commit comments