@@ -9,11 +9,11 @@ describe('JWT class tests', () => {
9
9
const param = 'param' ;
10
10
const validity = 1 ;
11
11
12
- it ( 'Should throw error for invalid token in JWT.decode' , async ( ) => {
13
- beforeEach ( ( ) => {
14
- readFileSpy . mockClear ( ) ;
15
- } ) ;
12
+ beforeEach ( ( ) => {
13
+ readFileSpy . mockClear ( ) ;
14
+ } ) ;
16
15
16
+ it ( 'Should throw error for invalid token in JWT.decode' , async ( ) => {
17
17
try {
18
18
await JWT . decode ( 'abc' ) ;
19
19
} catch ( e ) {
@@ -24,10 +24,6 @@ describe('JWT class tests', () => {
24
24
} ) ;
25
25
26
26
it ( 'Should generate a token for JWT.encode' , async ( ) => {
27
- beforeEach ( ( ) => {
28
- readFileSpy . mockClear ( ) ;
29
- } ) ;
30
-
31
27
const payload = new JwtPayload ( issuer , audience , subject , param , validity ) ;
32
28
const token = await JWT . encode ( payload ) ;
33
29
@@ -36,10 +32,6 @@ describe('JWT class tests', () => {
36
32
} ) ;
37
33
38
34
it ( 'Should decode a valid token for JWT.decode' , async ( ) => {
39
- beforeEach ( ( ) => {
40
- readFileSpy . mockClear ( ) ;
41
- } ) ;
42
-
43
35
const payload = new JwtPayload ( issuer , audience , subject , param , validity ) ;
44
36
const token = await JWT . encode ( payload ) ;
45
37
const decoded = await JWT . decode ( token ) ;
@@ -49,10 +41,6 @@ describe('JWT class tests', () => {
49
41
} ) ;
50
42
51
43
it ( 'Should parse an expired token for JWT.decode' , async ( ) => {
52
- beforeEach ( ( ) => {
53
- readFileSpy . mockClear ( ) ;
54
- } ) ;
55
-
56
44
const time = Math . floor ( Date . now ( ) / 1000 ) ;
57
45
58
46
const payload = {
@@ -71,10 +59,6 @@ describe('JWT class tests', () => {
71
59
} ) ;
72
60
73
61
it ( 'Should throw error for invalid token in JWT.validate' , async ( ) => {
74
- beforeEach ( ( ) => {
75
- readFileSpy . mockClear ( ) ;
76
- } ) ;
77
-
78
62
try {
79
63
await JWT . validate ( 'abc' ) ;
80
64
} catch ( e ) {
@@ -85,10 +69,6 @@ describe('JWT class tests', () => {
85
69
} ) ;
86
70
87
71
it ( 'Should validate a valid token for JWT.validate' , async ( ) => {
88
- beforeEach ( ( ) => {
89
- readFileSpy . mockClear ( ) ;
90
- } ) ;
91
-
92
72
const payload = new JwtPayload ( issuer , audience , subject , param , validity ) ;
93
73
const token = await JWT . encode ( payload ) ;
94
74
const decoded = await JWT . validate ( token ) ;
@@ -98,10 +78,6 @@ describe('JWT class tests', () => {
98
78
} ) ;
99
79
100
80
it ( 'Should validate a token expiry for JWT.validate' , async ( ) => {
101
- beforeEach ( ( ) => {
102
- readFileSpy . mockClear ( ) ;
103
- } ) ;
104
-
105
81
const time = Math . floor ( Date . now ( ) / 1000 ) ;
106
82
107
83
const payload = {
0 commit comments