@@ -32,9 +32,7 @@ describe('VerifyComponent', () => {
32
32
const config : TestModuleMetadata = cloneDeep ( Testing . BASE_TEST_CONFIG ) ;
33
33
34
34
config . declarations . push ( VerifyComponent ) ;
35
-
36
35
config . imports . push ( SharedModule ) ;
37
-
38
36
config . providers . push ( HttpService ) ;
39
37
config . providers . push ( ApiService ) ;
40
38
config . providers . push ( AccountService ) ;
@@ -57,18 +55,14 @@ describe('VerifyComponent', () => {
57
55
} ) ;
58
56
59
57
config . providers . push ( EventService ) ;
60
-
61
- // Define the re-captcha element as a custom element so it's only mocked out
62
58
config . schemas = [ CUSTOM_ELEMENTS_SCHEMA ] ;
63
59
64
60
await TestBed . configureTestingModule ( config ) . compileComponents ( ) ;
65
61
66
62
httpMock = TestBed . get ( HttpTestingController ) ;
67
-
68
63
accountService = TestBed . get ( AccountService ) ;
69
64
70
65
const authResponse = new AuthResponse ( authResponseData ) ;
71
-
72
66
accountService . setAccount ( authResponse . getAccountVO ( ) ) ;
73
67
accountService . setArchive ( authResponse . getArchiveVO ( ) ) ;
74
68
@@ -79,7 +73,6 @@ describe('VerifyComponent', () => {
79
73
80
74
afterEach ( ( ) => {
81
75
accountService . clear ( ) ;
82
- // httpMock.verify();
83
76
} ) ;
84
77
85
78
it ( 'should create' , async ( ) => {
@@ -88,80 +81,46 @@ describe('VerifyComponent', () => {
88
81
expect ( component ) . toBeTruthy ( ) ;
89
82
} ) ;
90
83
91
- // it('should send email verification if sendEmail flag set', async () => {
92
- // await init(defaultAuthData, {sendEmail: true});
93
- // const req = httpMock.expectOne(`${environment.apiUrl}/auth/resendMailCreatedAccount`);
94
- // });
95
-
96
- // it('should send sms verification if sendSms flag set', async () => {
97
- // await init(defaultAuthData, {sendSms: true});
98
- // const req = httpMock.expectOne(`${environment.apiUrl}/auth/resendTextCreatedAccount`);
99
- // });
100
-
101
84
it ( 'should require only email verification if only email unverified' , async ( ) => {
102
85
await init ( defaultAuthData , { sendEmail : true } ) ;
103
86
104
- expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
105
- expect ( component . needsEmail ) . toBeTruthy ( ) ;
106
- expect ( component . needsPhone ) . toBeFalsy ( ) ;
107
-
108
- const account = accountService . getAccount ( ) ;
109
-
110
- expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
111
- expect ( account . phoneNeedsVerification ( ) ) . toBeFalse ( ) ;
87
+ expect ( component . currentVerifyFlow ) . toBe ( 'email' ) ;
88
+ expect ( component . needsEmail ) . toBeTrue ( ) ;
89
+ expect ( component . needsPhone ) . toBeFalse ( ) ;
112
90
} ) ;
113
91
114
92
it ( 'should require only phone verification if only phone unverified' , async ( ) => {
115
93
const unverifiedPhoneData = require ( '@root/test/responses/auth.verify.unverifiedPhone.success.json' ) ;
116
94
await init ( unverifiedPhoneData , { sendSms : true } ) ;
117
95
118
- expect ( component . verifyingPhone ) . toBeTruthy ( ) ;
119
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
120
- expect ( component . needsEmail ) . toBeFalsy ( ) ;
96
+ expect ( component . currentVerifyFlow ) . toBe ( 'phone' ) ;
97
+ expect ( component . needsPhone ) . toBeTrue ( ) ;
98
+ expect ( component . needsEmail ) . toBeFalse ( ) ;
121
99
} ) ;
122
100
123
101
it ( 'should require verification of both if both unverified, and verify email first' , async ( ) => {
124
102
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
125
103
await init ( unverifiedBothData ) ;
126
104
127
- expect ( component . verifyingEmail ) . toBeTrue ( ) ;
128
- expect ( component . verifyingPhone ) . toBeFalse ( ) ;
129
-
105
+ expect ( component . currentVerifyFlow ) . toBe ( 'email' ) ;
130
106
expect ( component . needsEmail ) . toBeTrue ( ) ;
131
107
expect ( component . needsPhone ) . toBeTrue ( ) ;
132
-
133
- const account = accountService . getAccount ( ) ;
134
-
135
- expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
136
- expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
137
108
} ) ;
138
109
139
110
it ( 'should verify email and then switch to phone verification if needed' , async ( ) => {
140
111
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
141
-
142
- // Remove query params -- let accountService drive both verifications
143
112
await init ( unverifiedBothData ) ;
144
113
145
- expect ( component . verifyingEmail ) . toBeTrue ( ) ;
146
- expect ( component . needsPhone ) . toBeTrue ( ) ;
147
- expect ( component . needsEmail ) . toBeTrue ( ) ;
148
-
149
114
const account = accountService . getAccount ( ) ;
150
115
151
116
expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
152
117
expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
153
118
154
119
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
155
120
expect ( component . waiting ) . toBeFalse ( ) ;
156
- expect ( component . verifyingEmail ) . toBeFalse ( ) ;
121
+ expect ( component . currentVerifyFlow ) . toBe ( 'phone' ) ;
157
122
expect ( component . needsEmail ) . toBeFalse ( ) ;
158
123
expect ( component . needsPhone ) . toBeTrue ( ) ;
159
- expect ( component . verifyingPhone ) . toBeTrue ( ) ;
160
-
161
- const updatedAccount = accountService . getAccount ( ) ;
162
-
163
- expect ( updatedAccount . emailNeedsVerification ( ) ) . toBeFalse ( ) ;
164
- expect ( updatedAccount . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
165
124
} ) ;
166
125
167
126
expect ( component . waiting ) . toBeTrue ( ) ;
@@ -176,11 +135,6 @@ describe('VerifyComponent', () => {
176
135
await init ( unverifiedEmailData , { sendEmail : true } ) ;
177
136
178
137
const finishSpy = spyOn ( component , 'finish' ) ;
179
-
180
- expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
181
- expect ( component . needsPhone ) . toBeFalsy ( ) ;
182
- expect ( component . needsEmail ) . toBeTruthy ( ) ;
183
-
184
138
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
185
139
expect ( component . waiting ) . toBeFalsy ( ) ;
186
140
expect ( component . needsEmail ) . toBeFalsy ( ) ;
@@ -200,12 +154,6 @@ describe('VerifyComponent', () => {
200
154
await init ( unverifiedPhoneData , { sendSms : true } ) ;
201
155
202
156
const finishSpy = spyOn ( component , 'finish' ) ;
203
-
204
- expect ( component . verifyingPhone ) . toBeTruthy ( ) ;
205
- expect ( component . verifyingEmail ) . toBeFalsy ( ) ;
206
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
207
- expect ( component . needsEmail ) . toBeFalsy ( ) ;
208
-
209
157
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
210
158
expect ( component . waiting ) . toBeFalsy ( ) ;
211
159
expect ( component . needsEmail ) . toBeFalsy ( ) ;
@@ -224,8 +172,6 @@ describe('VerifyComponent', () => {
224
172
const unverifiedPhoneData = require ( '@root/test/responses/auth.verify.unverifiedPhone.success.json' ) ;
225
173
await init ( unverifiedPhoneData , { sendSms : true } ) ;
226
174
227
- // Testing environments might not have the site key enabled,
228
- // so force captchaEnabled to be true.
229
175
component . captchaEnabled = true ;
230
176
231
177
expect ( component . captchaPassed ) . toBeFalsy ( ) ;
@@ -236,19 +182,4 @@ describe('VerifyComponent', () => {
236
182
expect ( component . captchaPassed ) . toBeTruthy ( ) ;
237
183
expect ( component . canSendCodes ( 'phone' ) ) . toBeTruthy ( ) ;
238
184
} ) ;
239
-
240
- it ( 'should set flow to email when only email is unverified' , async ( ) => {
241
- await init ( defaultAuthData , { sendEmail : true } ) ;
242
-
243
- expect ( component . currentVerifyFlow ) . toBe ( 'email' ) ;
244
- expect ( component . formTitle ) . toBe ( 'Verify Email' ) ;
245
- } ) ;
246
-
247
- it ( 'should set flow to phone when only phone is unverified' , async ( ) => {
248
- const unverifiedPhoneData = require ( '@root/test/responses/auth.verify.unverifiedPhone.success.json' ) ;
249
- await init ( unverifiedPhoneData , { sendSms : true } ) ;
250
-
251
- expect ( component . currentVerifyFlow ) . toBe ( 'phone' ) ;
252
- expect ( component . formTitle ) . toBe ( 'Verify Phone Number' ) ;
253
- } ) ;
254
185
} ) ;
0 commit comments