1+ import { Test } from '@nestjs/testing' ;
12import {
23 createPrivateKey ,
34 createPublicKey ,
45 createSecretKey ,
56 generateKeyPairSync ,
67 KeyObject
78} from 'crypto' ;
8- import { Test } from '@nestjs/testing' ;
99import * as jwt from 'jsonwebtoken' ;
1010import {
1111 JwtModuleOptions ,
@@ -306,10 +306,7 @@ describe('JwtService', () => {
306306 const testPayload : string = getRandomString ( ) ;
307307
308308 beforeAll ( async ( ) => {
309- jwtService = await setup ( {
310- ...config ,
311- secretOrKeyProvider : undefined
312- } ) ;
309+ jwtService = await setup ( { ...config , secretOrKeyProvider : undefined } ) ;
313310 } ) ;
314311
315312 const secret = 'custom_secret' ;
@@ -401,9 +398,7 @@ describe('JwtService', () => {
401398 } ) ;
402399
403400 describe ( 'should use invalid sign options' , ( ) => {
404- const signOptions : jwt . SignOptions = {
405- expiresIn : '1d'
406- } ;
401+ const signOptions : jwt . SignOptions = { expiresIn : '1d' } ;
407402
408403 let jwtService : JwtService ;
409404 const testPayloadStr : string = getRandomString ( ) ;
@@ -417,7 +412,7 @@ describe('JwtService', () => {
417412 expect ( ( ) =>
418413 // @ts -expect-error
419414 jwtService . sign ( testPayloadStr , { expiresIn : 60 } )
420- ) . toThrowError (
415+ ) . toThrow (
421416 'Payload as string is not allowed with the following sign options: expiresIn'
422417 ) ;
423418 } ) ;
@@ -426,7 +421,7 @@ describe('JwtService', () => {
426421 expect ( ( ) =>
427422 // @ts -expect-error
428423 jwtService . signAsync ( testPayloadStr , { notBefore : 60 } )
429- ) . toThrowError (
424+ ) . toThrow (
430425 'Payload as string is not allowed with the following sign options: expiresIn, notBefore'
431426 ) ;
432427 } ) ;
@@ -442,13 +437,13 @@ describe('JwtService', () => {
442437 } ) ;
443438
444439 it ( 'should "sign" expect errors using "payload" string with already defined invalid sign options' , ( ) => {
445- expect ( ( ) => jwtService . sign ( testPayloadStr ) ) . toThrowError (
440+ expect ( ( ) => jwtService . sign ( testPayloadStr ) ) . toThrow (
446441 'Payload as string is not allowed with the following sign options: expiresIn'
447442 ) ;
448443 } ) ;
449444
450445 it ( 'should "signAsync" expect errors using "payload" string with already defined invalid sign options' , ( ) => {
451- expect ( ( ) => jwtService . signAsync ( testPayloadStr ) ) . toThrowError (
446+ expect ( ( ) => jwtService . signAsync ( testPayloadStr ) ) . toThrow (
452447 'Payload as string is not allowed with the following sign options: expiresIn'
453448 ) ;
454449 } ) ;
0 commit comments