File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1134,6 +1134,31 @@ describe('Router', function () {
1134
1134
done ( ) ;
1135
1135
} ) ;
1136
1136
1137
+ it ( 'generates URL for given route name with params and query params' , function ( done ) {
1138
+ var app = new Koa ( ) ;
1139
+ var router = new Router ( ) ;
1140
+ router . get ( 'categories' , '/categories/:name' , function ( ctx ) {
1141
+ ctx . status = 204 ;
1142
+ } ) ;
1143
+ var url = router . url ( 'categories' , { name : 'programming' } , {
1144
+ query : { page : 3 , limit : 10 }
1145
+ } ) ;
1146
+ url . should . equal ( '/categories/programming?page=3&limit=10' ) ;
1147
+ done ( ) ;
1148
+ } )
1149
+
1150
+ it ( 'generates URL for given route name without params and query params' , function ( done ) {
1151
+ var app = new Koa ( ) ;
1152
+ var router = new Router ( ) ;
1153
+ router . get ( 'category' , '/category' , function ( ctx ) {
1154
+ ctx . status = 204 ;
1155
+ } ) ;
1156
+ var url = router . url ( 'category' , {
1157
+ query : { page : 3 , limit : 10 }
1158
+ } ) ;
1159
+ url . should . equal ( '/category?page=3&limit=10' ) ;
1160
+ done ( ) ;
1161
+ } )
1137
1162
} ) ;
1138
1163
1139
1164
describe ( 'Router#param()' , function ( ) {
You can’t perform that action at this time.
0 commit comments