@@ -125,78 +125,78 @@ describe('platform_browser/recaptcha/recaptcha_enterprise_verifier', () => {
125
125
} ) ;
126
126
} ) ;
127
127
128
- context ( 'handleRecaptchaFlow' , ( ) => {
129
- let mockAuthInstance : AuthInternal ;
130
- let mockRequest : any ;
131
- let mockActionMethod : sinon . SinonStub ;
128
+ context ( 'handleRecaptchaFlow' , ( ) => {
129
+ let mockAuthInstance : AuthInternal ;
130
+ let mockRequest : any ;
131
+ let mockActionMethod : sinon . SinonStub ;
132
+
133
+ beforeEach ( async ( ) => {
134
+ mockAuthInstance = await testAuth ( ) ;
135
+ mockRequest = { } ;
136
+ mockActionMethod = sinon . stub ( ) ;
137
+ } ) ;
132
138
133
- beforeEach ( async ( ) => {
134
- mockAuthInstance = await testAuth ( ) ;
135
- mockRequest = { } ;
136
- mockActionMethod = sinon . stub ( ) ;
137
- } ) ;
139
+ afterEach ( ( ) => {
140
+ sinon . restore ( ) ;
141
+ } ) ;
138
142
139
- afterEach ( ( ) => {
140
- sinon . restore ( ) ;
141
- } ) ;
143
+ it ( 'should handle recaptcha when emailPasswordEnabled is true' , async ( ) => {
144
+ sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
145
+ emailPasswordEnabled : true ,
146
+ siteKey : 'mock_site_key'
147
+ } ) ;
148
+ mockActionMethod . resolves ( 'success' ) ;
149
+
150
+ const result = await handleRecaptchaFlow (
151
+ mockAuthInstance ,
152
+ mockRequest ,
153
+ RecaptchaActionName . GET_OOB_CODE ,
154
+ mockActionMethod
155
+ ) ;
142
156
143
- it ( 'should handle recaptcha when emailPasswordEnabled is true' , async ( ) => {
144
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
145
- emailPasswordEnabled : true ,
146
- siteKey : "mock_site_key"
157
+ expect ( result ) . to . equal ( 'success' ) ;
158
+ expect ( mockActionMethod ) . to . have . been . calledOnce ;
159
+ // Add more assertions as needed, e.g., checking if injectRecaptchaFields was called
147
160
} ) ;
148
- mockActionMethod . resolves ( 'success' ) ;
149
-
150
- const result = await handleRecaptchaFlow (
151
- mockAuthInstance ,
152
- mockRequest ,
153
- RecaptchaActionName . GET_OOB_CODE ,
154
- mockActionMethod
155
- ) ;
156
-
157
- expect ( result ) . to . equal ( 'success' ) ;
158
- expect ( mockActionMethod ) . to . have . been . calledOnce ;
159
- // Add more assertions as needed, e.g., checking if injectRecaptchaFields was called
160
- } ) ;
161
161
162
- it ( 'should handle action without recaptcha when emailPasswordEnabled is false and no error' , async ( ) => {
163
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
164
- emailPasswordEnabled : false ,
165
- siteKey : 'mock_site_key'
166
- } ) ;
167
- mockActionMethod . resolves ( 'success' ) ;
162
+ it ( 'should handle action without recaptcha when emailPasswordEnabled is false and no error' , async ( ) => {
163
+ sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
164
+ emailPasswordEnabled : false ,
165
+ siteKey : 'mock_site_key'
166
+ } ) ;
167
+ mockActionMethod . resolves ( 'success' ) ;
168
+
169
+ const result = await handleRecaptchaFlow (
170
+ mockAuthInstance ,
171
+ mockRequest ,
172
+ RecaptchaActionName . GET_OOB_CODE ,
173
+ mockActionMethod
174
+ ) ;
168
175
169
- const result = await handleRecaptchaFlow (
170
- mockAuthInstance ,
171
- mockRequest ,
172
- RecaptchaActionName . GET_OOB_CODE ,
173
- mockActionMethod
174
- ) ;
176
+ expect ( result ) . to . equal ( 'success' ) ;
177
+ expect ( mockActionMethod ) . to . have . been . calledOnce ;
178
+ } ) ;
175
179
176
- expect ( result ) . to . equal ( 'success' ) ;
177
- expect ( mockActionMethod ) . to . have . been . calledOnce ;
178
- } ) ;
180
+ it ( 'should handle MISSING_RECAPTCHA_TOKEN error when emailPasswordEnabled is false' , async ( ) => {
181
+ sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
182
+ emailPasswordEnabled : false ,
183
+ siteKey : 'mock_site_key'
184
+ } ) ;
185
+ mockActionMethod . onFirstCall ( ) . rejects ( {
186
+ code : 'auth/MISSING_RECAPTCHA_TOKEN'
187
+ } ) ;
188
+ mockActionMethod . onSecondCall ( ) . resolves ( 'success-after-recaptcha' ) ;
189
+
190
+ const result = await handleRecaptchaFlow (
191
+ mockAuthInstance ,
192
+ mockRequest ,
193
+ RecaptchaActionName . GET_OOB_CODE ,
194
+ mockActionMethod
195
+ ) ;
179
196
180
- it ( 'should handle MISSING_RECAPTCHA_TOKEN error when emailPasswordEnabled is false' , async ( ) => {
181
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
182
- emailPasswordEnabled : false ,
183
- siteKey : 'mock_site_key'
184
- } ) ;
185
- mockActionMethod . onFirstCall ( ) . rejects ( {
186
- code : 'auth/MISSING_RECAPTCHA_TOKEN'
197
+ expect ( result ) . to . equal ( 'success-after-recaptcha' ) ;
198
+ expect ( mockActionMethod ) . to . have . been . calledTwice ;
199
+ // Add more assertions as needed, e.g., checking if injectRecaptchaFields was called
187
200
} ) ;
188
- mockActionMethod . onSecondCall ( ) . resolves ( 'success-after-recaptcha' ) ;
189
-
190
- const result = await handleRecaptchaFlow (
191
- mockAuthInstance ,
192
- mockRequest ,
193
- RecaptchaActionName . GET_OOB_CODE ,
194
- mockActionMethod
195
- ) ;
196
-
197
- expect ( result ) . to . equal ( 'success-after-recaptcha' ) ;
198
- expect ( mockActionMethod ) . to . have . been . calledTwice ;
199
- // Add more assertions as needed, e.g., checking if injectRecaptchaFields was called
200
201
} ) ;
201
202
} ) ;
202
- } ) ;
0 commit comments