@@ -368,17 +368,29 @@ describe('Router', function(){
368368 } )
369369
370370 describe ( '.use' , function ( ) {
371- it ( 'should require arguments ' , function ( ) {
372- var router = new Router ( ) ;
373- router . use . bind ( router ) . should . throw ( / r e q u i r e s m i d d l e w a r e f u n c t i o n / )
371+ it ( 'should require middleware ' , function ( ) {
372+ var router = new Router ( )
373+ assert . throws ( function ( ) { router . use ( '/' ) } , / r e q u i r e s a m i d d l e w a r e f u n c t i o n / )
374374 } )
375375
376- it ( 'should not accept non-functions' , function ( ) {
377- var router = new Router ( ) ;
378- router . use . bind ( router , '/' , 'hello' ) . should . throw ( / r e q u i r e s m i d d l e w a r e f u n c t i o n .* s t r i n g / )
379- router . use . bind ( router , '/' , 5 ) . should . throw ( / r e q u i r e s m i d d l e w a r e f u n c t i o n .* n u m b e r / )
380- router . use . bind ( router , '/' , null ) . should . throw ( / r e q u i r e s m i d d l e w a r e f u n c t i o n .* N u l l / )
381- router . use . bind ( router , '/' , new Date ( ) ) . should . throw ( / r e q u i r e s m i d d l e w a r e f u n c t i o n .* D a t e / )
376+ it ( 'should reject string as middleware' , function ( ) {
377+ var router = new Router ( )
378+ assert . throws ( function ( ) { router . use ( '/' , 'foo' ) } , / r e q u i r e s a m i d d l e w a r e f u n c t i o n b u t g o t a s t r i n g / )
379+ } )
380+
381+ it ( 'should reject number as middleware' , function ( ) {
382+ var router = new Router ( )
383+ assert . throws ( function ( ) { router . use ( '/' , 42 ) } , / r e q u i r e s a m i d d l e w a r e f u n c t i o n b u t g o t a n u m b e r / )
384+ } )
385+
386+ it ( 'should reject null as middleware' , function ( ) {
387+ var router = new Router ( )
388+ assert . throws ( function ( ) { router . use ( '/' , null ) } , / r e q u i r e s a m i d d l e w a r e f u n c t i o n b u t g o t a N u l l / )
389+ } )
390+
391+ it ( 'should reject Date as middleware' , function ( ) {
392+ var router = new Router ( )
393+ assert . throws ( function ( ) { router . use ( '/' , new Date ( ) ) } , / r e q u i r e s a m i d d l e w a r e f u n c t i o n b u t g o t a D a t e / )
382394 } )
383395
384396 it ( 'should be called for any URL' , function ( done ) {
0 commit comments