@@ -214,6 +214,44 @@ function runTestsWithRouter(router: RestRouter) {
214
214
expect ( route . pathParams ) . to . containEql ( { userId : '1' , format : 'json' } ) ;
215
215
} ) ;
216
216
217
+ it ( 'finds "GET /orders, /orders/{id}, /orders/{orderId}/shipments" endpoints' , ( ) => {
218
+ class TestController {
219
+ @get ( '/orders/{id}' )
220
+ async getOrderById ( @param . path . number ( 'id' ) id : number ) : Promise < object > {
221
+ return { id} ;
222
+ }
223
+ @get ( '/orders' )
224
+ async findOrders ( ) : Promise < object [ ] > {
225
+ return [ ] ;
226
+ }
227
+ // A path that overlaps with `/orders/{id}`. Please note a different var
228
+ // name is used - `{orderId}`
229
+ @get ( '/orders/{orderId}/shipments' )
230
+ async getShipmentsForOrder (
231
+ @param . path . number ( 'orderId' ) id : number ,
232
+ ) : Promise < object > {
233
+ return [ ] ;
234
+ }
235
+ }
236
+
237
+ const table = givenRoutingTable ( ) ;
238
+ const spec = getControllerSpec ( TestController ) ;
239
+ table . registerController ( spec , TestController ) ;
240
+
241
+ const findAndCheckRoute = ( url : string , expectedPath : string ) => {
242
+ let request = givenRequest ( {
243
+ method : 'get' ,
244
+ url,
245
+ } ) ;
246
+ const route = table . find ( request ) ;
247
+ expect ( route . path ) . to . eql ( expectedPath ) ;
248
+ } ;
249
+
250
+ findAndCheckRoute ( '/orders/1' , '/orders/{id}' ) ;
251
+ findAndCheckRoute ( '/orders/1/shipments' , '/orders/{orderId}/shipments' ) ;
252
+ findAndCheckRoute ( '/orders' , '/orders' ) ;
253
+ } ) ;
254
+
217
255
it ( 'throws if router is not found' , ( ) => {
218
256
const table = givenRoutingTable ( ) ;
219
257
0 commit comments