1
1
/*eslint-env mocha */
2
- import React from 'react'
3
- import Route from '../Route'
4
-
5
- import assert from 'assert'
6
2
import expect from 'expect'
3
+ import React from 'react'
7
4
import { createMemoryHistory } from 'history'
8
5
import { createRoutes } from '../RouteUtils'
9
6
import matchRoutes from '../matchRoutes'
7
+ import Route from '../Route'
10
8
11
9
describe ( 'matchRoutes' , function ( ) {
12
10
@@ -67,7 +65,7 @@ describe('matchRoutes', function () {
67
65
describe ( 'when the location matches an index route' , function ( ) {
68
66
it ( 'matches the correct routes' , function ( done ) {
69
67
matchRoutes ( routes , createLocation ( '/users' ) , function ( error , match ) {
70
- assert ( match )
68
+ expect ( match ) . toExist ( )
71
69
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UsersIndexRoute ] )
72
70
done ( )
73
71
} )
@@ -77,7 +75,7 @@ describe('matchRoutes', function () {
77
75
describe ( 'when the location matches a nested route with params' , function ( ) {
78
76
it ( 'matches the correct routes and params' , function ( done ) {
79
77
matchRoutes ( routes , createLocation ( '/users/5' ) , function ( error , match ) {
80
- assert ( match )
78
+ expect ( match ) . toExist ( )
81
79
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UserRoute ] )
82
80
expect ( match . params ) . toEqual ( { userID : '5' } )
83
81
done ( )
@@ -88,7 +86,7 @@ describe('matchRoutes', function () {
88
86
describe ( 'when the location matches a deeply nested route with params' , function ( ) {
89
87
it ( 'matches the correct routes and params' , function ( done ) {
90
88
matchRoutes ( routes , createLocation ( '/users/5/abc' ) , function ( error , match ) {
91
- assert ( match )
89
+ expect ( match ) . toExist ( )
92
90
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UserRoute , PostRoute ] )
93
91
expect ( match . params ) . toEqual ( { userID : '5' , postID : 'abc' } )
94
92
done ( )
@@ -99,7 +97,7 @@ describe('matchRoutes', function () {
99
97
describe ( 'when the location matches a nested route with multiple splat params' , function ( ) {
100
98
it ( 'matches the correct routes and params' , function ( done ) {
101
99
matchRoutes ( routes , createLocation ( '/files/a/b/c.jpg' ) , function ( error , match ) {
102
- assert ( match )
100
+ expect ( match ) . toExist ( )
103
101
expect ( match . routes ) . toEqual ( [ FilesRoute ] )
104
102
expect ( match . params ) . toEqual ( { splat : [ 'a' , 'b/c' ] } )
105
103
done ( )
@@ -110,7 +108,7 @@ describe('matchRoutes', function () {
110
108
describe ( 'when the location matches a route with hash' , function ( ) {
111
109
it ( 'matches the correct routes' , function ( done ) {
112
110
matchRoutes ( routes , createLocation ( '/users#about' ) , function ( error , match ) {
113
- assert ( match )
111
+ expect ( match ) . toExist ( )
114
112
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UsersIndexRoute ] )
115
113
done ( )
116
114
} )
@@ -120,7 +118,7 @@ describe('matchRoutes', function () {
120
118
describe ( 'when the location matches a deeply nested route with params and hash' , function ( ) {
121
119
it ( 'matches the correct routes and params' , function ( done ) {
122
120
matchRoutes ( routes , createLocation ( '/users/5/abc#about' ) , function ( error , match ) {
123
- assert ( match )
121
+ expect ( match ) . toExist ( )
124
122
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UserRoute , PostRoute ] )
125
123
expect ( match . params ) . toEqual ( { userID : '5' , postID : 'abc' } )
126
124
done ( )
@@ -131,7 +129,7 @@ describe('matchRoutes', function () {
131
129
describe ( 'when the location matches an absolute route' , function ( ) {
132
130
it ( 'matches the correct routes' , function ( done ) {
133
131
matchRoutes ( routes , createLocation ( '/about' ) , function ( error , match ) {
134
- assert ( match )
132
+ expect ( match ) . toExist ( )
135
133
expect ( match . routes ) . toEqual ( [ AboutRoute ] )
136
134
done ( )
137
135
} )
@@ -141,7 +139,7 @@ describe('matchRoutes', function () {
141
139
describe ( 'when the location does not match any routes' , function ( ) {
142
140
it ( 'matches the "catch-all" route' , function ( done ) {
143
141
matchRoutes ( routes , createLocation ( '/not-found' ) , function ( error , match ) {
144
- assert ( match )
142
+ expect ( match ) . toExist ( )
145
143
expect ( match . routes ) . toEqual ( [ CatchAllRoute ] )
146
144
done ( )
147
145
} )
@@ -155,7 +153,7 @@ describe('matchRoutes', function () {
155
153
describe ( 'when the location matches a nested absolute route' , function ( ) {
156
154
it ( 'matches the correct routes' , function ( done ) {
157
155
matchRoutes ( routes , createLocation ( '/team' ) , function ( error , match ) {
158
- assert ( match )
156
+ expect ( match ) . toExist ( )
159
157
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , TeamRoute ] )
160
158
done ( )
161
159
} )
@@ -165,7 +163,7 @@ describe('matchRoutes', function () {
165
163
describe ( 'when the location matches an absolute route nested under a route with params' , function ( ) {
166
164
it ( 'matches the correct routes and params' , function ( done ) {
167
165
matchRoutes ( routes , createLocation ( '/profile' ) , function ( error , match ) {
168
- assert ( match )
166
+ expect ( match ) . toExist ( )
169
167
expect ( match . routes ) . toEqual ( [ RootRoute , UsersRoute , UserRoute , ProfileRoute ] )
170
168
expect ( match . params ) . toEqual ( { } ) // no userID param
171
169
done ( )
@@ -236,7 +234,7 @@ describe('matchRoutes', function () {
236
234
237
235
it ( 'when getChildRoutes callback returns reactElements' , function ( done ) {
238
236
matchRoutes ( jsxRoutes , createLocation ( '/users/5' ) , function ( error , match ) {
239
- assert ( match )
237
+ expect ( match ) . toExist ( )
240
238
expect ( match . routes . map ( r => r . path ) ) . toEqual ( [ 'users' , ':userID' ] )
241
239
expect ( match . params ) . toEqual ( { userID : '5' } )
242
240
done ( )
@@ -245,7 +243,7 @@ describe('matchRoutes', function () {
245
243
246
244
it ( 'when getIndexRoute callback returns reactElements' , function ( done ) {
247
245
matchRoutes ( jsxRoutes , createLocation ( '/users' ) , function ( error , match ) {
248
- assert ( match )
246
+ expect ( match ) . toExist ( )
249
247
expect ( match . routes . map ( r => r . name ) ) . toEqual ( [ 'users' , 'jsx' ] )
250
248
done ( )
251
249
} )
0 commit comments