@@ -10,6 +10,7 @@ import {
1010 env ,
1111 mockDateNow ,
1212} from "../../fixtures/fixture" ;
13+ import { DevFlag } from "../../../src/typeDefinitions/verify.types" ;
1314
1415describe ( "verifyCommand" , ( ) => {
1516 beforeEach ( ( ) => {
@@ -24,6 +25,68 @@ describe("verifyCommand", () => {
2425 jest . spyOn ( Date , "now" ) . mockRestore ( ) ;
2526 } ) ;
2627
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+
2790 test ( "should return JSON response when response is ok" , async ( ) => {
2891 jest . spyOn ( global , "fetch" ) . mockResolvedValueOnce ( {
2992 ok : true ,
0 commit comments