@@ -231,35 +231,29 @@ describe('expires', function() {
231231 } ) ;
232232 } ) ;
233233
234- // TODO an exp of -Infinity should fail validation
235- it ( 'should set null "exp" when given -Infinity' , function ( done ) {
236- signWithExpiresIn ( undefined , { exp : - Infinity } , ( err , token ) => {
237- const decoded = jwt . decode ( token ) ;
234+ it ( 'should throw error when "exp" is -Infinity' , function ( done ) {
235+ signWithExpiresIn ( undefined , { exp : - Infinity } , ( err ) => {
238236 testUtils . asyncCheck ( done , ( ) => {
239- expect ( err ) . to . be . null ;
240- expect ( decoded ) . to . have . property ( 'exp ' , null ) ;
237+ expect ( err ) . to . be . instanceOf ( Error ) ;
238+ expect ( err ) . to . have . property ( 'message ' , '"exp" should be a number of seconds' ) ;
241239 } ) ;
242240 } ) ;
243241 } ) ;
244242
245- // TODO an exp of Infinity should fail validation
246- it ( 'should set null "exp" when given value Infinity' , function ( done ) {
247- signWithExpiresIn ( undefined , { exp : Infinity } , ( err , token ) => {
248- const decoded = jwt . decode ( token ) ;
243+ it ( 'should throw error when "exp" is Infinity' , function ( done ) {
244+ signWithExpiresIn ( undefined , { exp : Infinity } , ( err ) => {
249245 testUtils . asyncCheck ( done , ( ) => {
250- expect ( err ) . to . be . null ;
251- expect ( decoded ) . to . have . property ( 'exp ' , null ) ;
246+ expect ( err ) . to . be . instanceOf ( Error ) ;
247+ expect ( err ) . to . have . property ( 'message ' , '"exp" should be a number of seconds' ) ;
252248 } ) ;
253249 } ) ;
254250 } ) ;
255251
256- // TODO an exp of NaN should fail validation
257- it ( 'should set null "exp" when given value NaN' , function ( done ) {
258- signWithExpiresIn ( undefined , { exp : NaN } , ( err , token ) => {
259- const decoded = jwt . decode ( token ) ;
252+ it ( 'should throw error when "exp" is NaN' , function ( done ) {
253+ signWithExpiresIn ( undefined , { exp : NaN } , ( err ) => {
260254 testUtils . asyncCheck ( done , ( ) => {
261- expect ( err ) . to . be . null ;
262- expect ( decoded ) . to . have . property ( 'exp ' , null ) ;
255+ expect ( err ) . to . be . instanceOf ( Error ) ;
256+ expect ( err ) . to . have . property ( 'message ' , '"exp" should be a number of seconds' ) ;
263257 } ) ;
264258 } ) ;
265259 } ) ;
0 commit comments