@@ -104,6 +104,11 @@ describe('VerifyComponent', () => {
104
104
expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
105
105
expect ( component . needsEmail ) . toBeTruthy ( ) ;
106
106
expect ( component . needsPhone ) . toBeFalsy ( ) ;
107
+
108
+ const account = accountService . getAccount ( ) ;
109
+
110
+ expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
111
+ expect ( account . phoneNeedsVerification ( ) ) . toBeFalse ( ) ;
107
112
} ) ;
108
113
109
114
it ( 'should require only phone verification if only phone unverified' , async ( ) => {
@@ -117,30 +122,49 @@ describe('VerifyComponent', () => {
117
122
118
123
it ( 'should require verification of both if both unverified, and verify email first' , async ( ) => {
119
124
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
120
- await init ( unverifiedBothData , { sendEmail : true , sendSms : true } ) ;
125
+ await init ( unverifiedBothData ) ;
121
126
122
- expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
123
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
124
- expect ( component . needsEmail ) . toBeTruthy ( ) ;
127
+ expect ( component . verifyingEmail ) . toBeTrue ( ) ;
128
+ expect ( component . verifyingPhone ) . toBeFalse ( ) ;
129
+
130
+ expect ( component . needsEmail ) . toBeTrue ( ) ;
131
+ expect ( component . needsPhone ) . toBeTrue ( ) ;
132
+
133
+ const account = accountService . getAccount ( ) ;
134
+
135
+ expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
136
+ expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
125
137
} ) ;
126
138
127
139
it ( 'should verify email and then switch to phone verification if needed' , async ( ) => {
128
140
const unverifiedBothData = require ( '@root/test/responses/auth.verify.unverifiedBoth.success.json' ) ;
129
- await init ( unverifiedBothData , { sendEmail : true , sendSms : true } ) ;
130
141
131
- expect ( component . verifyingEmail ) . toBeTruthy ( ) ;
132
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
133
- expect ( component . needsEmail ) . toBeTruthy ( ) ;
142
+ // Remove query params -- let accountService drive both verifications
143
+ await init ( unverifiedBothData ) ;
144
+
145
+ expect ( component . verifyingEmail ) . toBeTrue ( ) ;
146
+ expect ( component . needsPhone ) . toBeTrue ( ) ;
147
+ expect ( component . needsEmail ) . toBeTrue ( ) ;
148
+
149
+ const account = accountService . getAccount ( ) ;
150
+
151
+ expect ( account . emailNeedsVerification ( ) ) . toBeTrue ( ) ;
152
+ expect ( account . phoneNeedsVerification ( ) ) . toBeTrue ( ) ;
134
153
135
154
component . onSubmit ( component . verifyForm . value ) . then ( ( ) => {
136
- expect ( component . waiting ) . toBeFalsy ( ) ;
137
- expect ( component . verifyingEmail ) . toBeFalsy ( ) ;
138
- expect ( component . needsEmail ) . toBeFalsy ( ) ;
139
- expect ( component . needsPhone ) . toBeTruthy ( ) ;
140
- expect ( component . verifyingPhone ) . toBeTruthy ( ) ;
155
+ expect ( component . waiting ) . toBeFalse ( ) ;
156
+ expect ( component . verifyingEmail ) . toBeFalse ( ) ;
157
+ expect ( component . needsEmail ) . toBeFalse ( ) ;
158
+ 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 ( ) ;
141
165
} ) ;
142
166
143
- expect ( component . waiting ) . toBeTruthy ( ) ;
167
+ expect ( component . waiting ) . toBeTrue ( ) ;
144
168
145
169
const verifyEmailResponse = require ( '@root/test/responses/auth.verify.verifyEmailThenPhone.success.json' ) ;
146
170
const req = httpMock . expectOne ( `${ environment . apiUrl } /auth/verify` ) ;
0 commit comments