1+ import { Test } from '@nestjs/testing' ;
12import {
23createPrivateKey ,
34createPublicKey ,
45createSecretKey ,
56generateKeyPairSync ,
67KeyObject
78} from 'crypto' ;
8- import { Test } from '@nestjs/testing' ;
99import * as jwt from 'jsonwebtoken' ;
1010import {
1111JwtModuleOptions ,
@@ -306,10 +306,7 @@ describe('JwtService', () => {
306306const testPayload :string = getRandomString ( ) ;
307307
308308beforeAll ( async ( ) => {
309- jwtService = await setup ( {
310- ...config ,
311- secretOrKeyProvider :undefined
312- } ) ;
309+ jwtService = await setup ( { ...config , secretOrKeyProvider :undefined } ) ;
313310} ) ;
314311
315312const secret = 'custom_secret' ;
@@ -401,9 +398,7 @@ describe('JwtService', () => {
401398} ) ;
402399
403400describe ( 'should use invalid sign options' , ( ) => {
404- const signOptions :jwt . SignOptions = {
405- expiresIn :'1d'
406- } ;
401+ const signOptions :jwt . SignOptions = { expiresIn :'1d' } ;
407402
408403let jwtService :JwtService ;
409404const testPayloadStr :string = getRandomString ( ) ;
@@ -417,7 +412,7 @@ describe('JwtService', () => {
417412expect ( ( ) =>
418413//@ts -expect-error
419414jwtService . 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', () => {
426421expect ( ( ) =>
427422//@ts -expect-error
428423jwtService . 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
444439it ( '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
450445it ( '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} ) ;