@@ -19,19 +19,19 @@ describe("verifyCommand", () => {
19
19
jest . mock ( "../../../src/utils/generateUniqueToken" , ( ) => ( {
20
20
generateUniqueToken : ( ) => Promise . resolve ( UNIQUE_TOKEN ) ,
21
21
} ) ) ;
22
+ jest . spyOn ( global , "fetch" ) . mockResolvedValue ( {
23
+ ok : true ,
24
+ status : 200 ,
25
+ json : jest . fn ( ) . mockResolvedValue ( discordUserData ) ,
26
+ } as unknown as Response ) ;
22
27
} ) ;
23
28
24
29
afterEach ( ( ) => {
25
30
jest . spyOn ( Date , "now" ) . mockRestore ( ) ;
31
+ jest . restoreAllMocks ( ) ;
26
32
} ) ;
27
33
28
34
test ( "should return message with verification site url when dev is false" , async ( ) => {
29
- jest . spyOn ( global , "fetch" ) . mockResolvedValueOnce ( {
30
- ok : true ,
31
- status : 200 ,
32
- json : jest . fn ( ) . mockResolvedValueOnce ( discordUserData ) ,
33
- } as unknown as Response ) ;
34
-
35
35
const { verifyCommand } = await import (
36
36
"../../../src/controllers/verifyCommand"
37
37
) ;
@@ -59,12 +59,6 @@ describe("verifyCommand", () => {
59
59
} ) ;
60
60
61
61
test ( "should return message with verification site url when dev is true" , async ( ) => {
62
- jest . spyOn ( global , "fetch" ) . mockResolvedValueOnce ( {
63
- ok : true ,
64
- status : 200 ,
65
- json : jest . fn ( ) . mockResolvedValueOnce ( discordUserData ) ,
66
- } as unknown as Response ) ;
67
-
68
62
const { verifyCommand } = await import (
69
63
"../../../src/controllers/verifyCommand"
70
64
) ;
@@ -88,12 +82,6 @@ describe("verifyCommand", () => {
88
82
} ) ;
89
83
90
84
test ( "should return JSON response when response is ok" , async ( ) => {
91
- jest . spyOn ( global , "fetch" ) . mockResolvedValueOnce ( {
92
- ok : true ,
93
- status : 200 ,
94
- json : jest . fn ( ) . mockResolvedValueOnce ( discordUserData ) ,
95
- } as unknown as Response ) ;
96
-
97
85
const { verifyCommand } = await import (
98
86
"../../../src/controllers/verifyCommand"
99
87
) ;
@@ -137,10 +125,10 @@ describe("verifyCommand", () => {
137
125
"../../../src/controllers/verifyCommand"
138
126
) ;
139
127
const result = await verifyCommand (
140
- 1233434 ,
141
- "sjkhdkjashdksjh " ,
142
- "test user " ,
143
- "sndbhsbgdj " ,
128
+ 1 ,
129
+ "userAvatarHash " ,
130
+ "userName " ,
131
+ "discriminator " ,
144
132
"2021-07-25T19:25:16.172000+00:00" ,
145
133
env
146
134
) ;
0 commit comments