@@ -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,89 +73,52 @@ describe('VerifyComponent', () => {
79
73
80
74
afterEach ( ( ) => {
81
75
accountService . clear ( ) ;
82
- // httpMock.verify();
83
76
} ) ;
84
77
85
78
it ( 'should create' , async ( ) => {
86
79
await init ( ) ;
87
-
88
80
expect ( component ) . toBeTruthy ( ) ;
89
81
} ) ;
90
82
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
83
it ( 'should require only email verification if only email unverified' , async ( ) => {
102
84
await init ( defaultAuthData , { sendEmail : true } ) ;
103
85
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 ( ) ;
86
+ expect ( component . currentVerifyFlow ) . toBe ( 'email' ) ;
87
+ expect ( component . needsEmail ) . toBeTrue ( ) ;
88
+ expect ( component . needsPhone ) . toBeFalse ( ) ;
112
89
} ) ;
113
90
114
91
it ( 'should require only phone verification if only phone unverified' , async ( ) => {
115
92
const unverifiedPhoneData = require ( '@root/test/responses/auth.verify.unverifiedPhone.success.json' ) ;
116
93
await init ( unverifiedPhoneData , { sendSms : true } ) ;
117
94
118
- expect ( component . verifyingPhone ) . toBeTruthy ( ) ;
119
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
120
- expect ( component . needsEmail ) . toBeFalsy ( ) ;
95
+ expect ( component . currentVerifyFlow ) . toBe ( 'phone' ) ;
96
+ expect ( component . needsPhone ) . toBeTrue ( ) ;
97
+ expect ( component . needsEmail ) . toBeFalse ( ) ;
121
98
} ) ;
122
99
123
100
it ( 'should require verification of both if both unverified, and verify email first' , async ( ) => {
124
101
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
125
102
await init ( unverifiedBothData ) ;
126
103
127
- expect ( component . verifyingEmail ) . toBeTrue ( ) ;
128
- expect ( component . verifyingPhone ) . toBeFalse ( ) ;
129
-
104
+ expect ( component . currentVerifyFlow ) . toBe ( 'email' ) ;
130
105
expect ( component . needsEmail ) . toBeTrue ( ) ;
131
106
expect ( component . needsPhone ) . toBeTrue ( ) ;
132
-
133
- const account = accountService . getAccount ( ) ;
134
-
135
- expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
136
- expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
137
107
} ) ;
138
108
139
109
it ( 'should verify email and then switch to phone verification if needed' , async ( ) => {
140
110
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
141
-
142
- // Remove query params -- let accountService drive both verifications
143
111
await init ( unverifiedBothData ) ;
144
112
145
- expect ( component . verifyingEmail ) . toBeTrue ( ) ;
146
- expect ( component . needsPhone ) . toBeTrue ( ) ;
147
- expect ( component . needsEmail ) . toBeTrue ( ) ;
148
-
149
113
const account = accountService . getAccount ( ) ;
150
-
151
114
expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
152
115
expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
153
116
154
117
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
155
118
expect ( component . waiting ) . toBeFalse ( ) ;
156
- expect ( component . verifyingEmail ) . toBeFalse ( ) ;
119
+ expect ( component . currentVerifyFlow ) . toBe ( 'phone' ) ;
157
120
expect ( component . needsEmail ) . toBeFalse ( ) ;
158
121
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
122
} ) ;
166
123
167
124
expect ( component . waiting ) . toBeTrue ( ) ;
@@ -176,11 +133,6 @@ describe('VerifyComponent', () => {
176
133
await init ( unverifiedEmailData , { sendEmail : true } ) ;
177
134
178
135
const finishSpy = spyOn ( component , 'finish' ) ;
179
-
180
- expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
181
- expect ( component . needsPhone ) . toBeFalsy ( ) ;
182
- expect ( component . needsEmail ) . toBeTruthy ( ) ;
183
-
184
136
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
185
137
expect ( component . waiting ) . toBeFalsy ( ) ;
186
138
expect ( component . needsEmail ) . toBeFalsy ( ) ;
@@ -200,12 +152,6 @@ describe('VerifyComponent', () => {
200
152
await init ( unverifiedPhoneData , { sendSms : true } ) ;
201
153
202
154
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
155
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
210
156
expect ( component . waiting ) . toBeFalsy ( ) ;
211
157
expect ( component . needsEmail ) . toBeFalsy ( ) ;
@@ -224,8 +170,6 @@ describe('VerifyComponent', () => {
224
170
const unverifiedPhoneData = require ( '@root/test/responses/auth.verify.unverifiedPhone.success.json' ) ;
225
171
await init ( unverifiedPhoneData , { sendSms : true } ) ;
226
172
227
- // Testing environments might not have the site key enabled,
228
- // so force captchaEnabled to be true.
229
173
component . captchaEnabled = true ;
230
174
231
175
expect ( component . captchaPassed ) . toBeFalsy ( ) ;
@@ -236,19 +180,4 @@ describe('VerifyComponent', () => {
236
180
expect ( component . captchaPassed ) . toBeTruthy ( ) ;
237
181
expect ( component . canSendCodes ( 'phone' ) ) . toBeTruthy ( ) ;
238
182
} ) ;
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
183
} ) ;
0 commit comments