@@ -10,6 +10,7 @@ import {
10
10
env ,
11
11
mockDateNow ,
12
12
} from "../../fixtures/fixture" ;
13
+ import { DevFlag } from "../../../src/typeDefinitions/verify.types" ;
13
14
14
15
describe ( "verifyCommand" , ( ) => {
15
16
beforeEach ( ( ) => {
@@ -24,6 +25,68 @@ describe("verifyCommand", () => {
24
25
jest . spyOn ( Date , "now" ) . mockRestore ( ) ;
25
26
} ) ;
26
27
28
+ 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
+ const { verifyCommand } = await import (
36
+ "../../../src/controllers/verifyCommand"
37
+ ) ;
38
+
39
+ const result = await verifyCommand (
40
+ 1 ,
41
+ "userAvatarHash" ,
42
+ "userName" ,
43
+ "discriminator" ,
44
+ "2021-07-25T19:25:16.172000+00:00" ,
45
+ env ,
46
+ {
47
+ value : false ,
48
+ type : 5 ,
49
+ name : "dev" ,
50
+ } as DevFlag
51
+ ) ;
52
+
53
+ const resultText = await result . text ( ) ;
54
+ const resultData = JSON . parse ( resultText ) ;
55
+
56
+ const verificationSiteURL = config ( env ) . VERIFICATION_SITE_URL ;
57
+ const message = `${ VERIFICATION_STRING } \n${ verificationSiteURL } /discord?token=${ UNIQUE_TOKEN } \n${ VERIFICATION_SUBSTRING } ` ;
58
+ expect ( resultData . data . content ) . toEqual ( message ) ;
59
+ } ) ;
60
+
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
+ const { verifyCommand } = await import (
69
+ "../../../src/controllers/verifyCommand"
70
+ ) ;
71
+
72
+ const result = await verifyCommand (
73
+ 1 ,
74
+ "userAvatarHash" ,
75
+ "userName" ,
76
+ "discriminator" ,
77
+ "2021-07-25T19:25:16.172000+00:00" ,
78
+ env ,
79
+ { value : true , type : 5 , name : "dev" } as DevFlag
80
+ ) ;
81
+
82
+ const resultText = await result . text ( ) ;
83
+ const resultData = JSON . parse ( resultText ) ;
84
+
85
+ const verificationSiteURL = config ( env ) . MAIN_SITE_URL ;
86
+ const message = `${ VERIFICATION_STRING } \n${ verificationSiteURL } /discord?dev=true&token=${ UNIQUE_TOKEN } \n${ VERIFICATION_SUBSTRING } ` ;
87
+ expect ( resultData . data . content ) . toEqual ( message ) ;
88
+ } ) ;
89
+
27
90
test ( "should return JSON response when response is ok" , async ( ) => {
28
91
jest . spyOn ( global , "fetch" ) . mockResolvedValueOnce ( {
29
92
ok : true ,
0 commit comments