@@ -19,19 +19,19 @@ describe("verifyCommand", () => {
1919 jest . mock ( "../../../src/utils/generateUniqueToken" , ( ) => ( {
2020 generateUniqueToken : ( ) => Promise . resolve ( UNIQUE_TOKEN ) ,
2121 } ) ) ;
22+ jest . spyOn ( global , "fetch" ) . mockResolvedValue ( {
23+ ok : true ,
24+ status : 200 ,
25+ json : jest . fn ( ) . mockResolvedValue ( discordUserData ) ,
26+ } as unknown as Response ) ;
2227 } ) ;
2328
2429 afterEach ( ( ) => {
2530 jest . spyOn ( Date , "now" ) . mockRestore ( ) ;
31+ jest . restoreAllMocks ( ) ;
2632 } ) ;
2733
2834 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-
3535 const { verifyCommand } = await import (
3636 "../../../src/controllers/verifyCommand"
3737 ) ;
@@ -59,12 +59,6 @@ describe("verifyCommand", () => {
5959 } ) ;
6060
6161 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-
6862 const { verifyCommand } = await import (
6963 "../../../src/controllers/verifyCommand"
7064 ) ;
@@ -88,12 +82,6 @@ describe("verifyCommand", () => {
8882 } ) ;
8983
9084 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-
9785 const { verifyCommand } = await import (
9886 "../../../src/controllers/verifyCommand"
9987 ) ;
@@ -137,10 +125,10 @@ describe("verifyCommand", () => {
137125 "../../../src/controllers/verifyCommand"
138126 ) ;
139127 const result = await verifyCommand (
140- 1233434 ,
141- "sjkhdkjashdksjh " ,
142- "test user " ,
143- "sndbhsbgdj " ,
128+ 1 ,
129+ "userAvatarHash " ,
130+ "userName " ,
131+ "discriminator " ,
144132 "2021-07-25T19:25:16.172000+00:00" ,
145133 env
146134 ) ;
0 commit comments