@@ -20,23 +20,16 @@ import chaiAsPromised from 'chai-as-promised';
20
20
import * as sinon from 'sinon' ;
21
21
import sinonChai from 'sinon-chai' ;
22
22
23
- import {
24
- Endpoint ,
25
- RecaptchaClientType ,
26
- RecaptchaVersion ,
27
- RecaptchaActionName
28
- } from '../../api' ;
23
+ import { Endpoint , RecaptchaClientType , RecaptchaVersion } from '../../api' ;
29
24
import { mockEndpointWithParams } from '../../../test/helpers/api/helper' ;
30
25
import { testAuth , TestAuth } from '../../../test/helpers/mock_auth' ;
31
26
import * as mockFetch from '../../../test/helpers/mock_fetch' ;
32
27
import { ServerError } from '../../api/errors' ;
33
- import { AuthInternal } from '../../model/auth' ;
34
28
35
29
import { MockGreCAPTCHATopLevel } from './recaptcha_mock' ;
36
30
import {
37
31
RecaptchaEnterpriseVerifier ,
38
- FAKE_TOKEN ,
39
- handleRecaptchaFlow
32
+ FAKE_TOKEN
40
33
} from './recaptcha_enterprise_verifier' ;
41
34
42
35
use ( chaiAsPromised ) ;
@@ -124,86 +117,4 @@ describe('platform_browser/recaptcha/recaptcha_enterprise_verifier', () => {
124
117
expect ( await verifier . verify ( ) ) . to . eq ( FAKE_TOKEN ) ;
125
118
} ) ;
126
119
} ) ;
127
-
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
- } ) ;
138
-
139
- afterEach ( ( ) => {
140
- sinon . restore ( ) ;
141
- } ) ;
142
-
143
- it ( 'should handle recaptcha when emailPasswordEnabled is true' , async ( ) => {
144
- if ( typeof window === 'undefined' ) {
145
- return ;
146
- }
147
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
148
- emailPasswordEnabled : true ,
149
- siteKey : 'mock_site_key'
150
- } ) ;
151
- mockActionMethod . resolves ( 'success' ) ;
152
-
153
- const result = await handleRecaptchaFlow (
154
- mockAuthInstance ,
155
- mockRequest ,
156
- RecaptchaActionName . GET_OOB_CODE ,
157
- mockActionMethod
158
- ) ;
159
-
160
- expect ( result ) . to . equal ( 'success' ) ;
161
- expect ( mockActionMethod ) . to . have . been . calledOnce ;
162
- } ) ;
163
-
164
- it ( 'should handle action without recaptcha when emailPasswordEnabled is false and no error' , async ( ) => {
165
- if ( typeof window === 'undefined' ) {
166
- return ;
167
- }
168
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
169
- emailPasswordEnabled : false ,
170
- siteKey : 'mock_site_key'
171
- } ) ;
172
- mockActionMethod . resolves ( 'success' ) ;
173
-
174
- const result = await handleRecaptchaFlow (
175
- mockAuthInstance ,
176
- mockRequest ,
177
- RecaptchaActionName . GET_OOB_CODE ,
178
- mockActionMethod
179
- ) ;
180
-
181
- expect ( result ) . to . equal ( 'success' ) ;
182
- expect ( mockActionMethod ) . to . have . been . calledOnce ;
183
- } ) ;
184
-
185
- it ( 'should handle MISSING_RECAPTCHA_TOKEN error when emailPasswordEnabled is false' , async ( ) => {
186
- if ( typeof window === 'undefined' ) {
187
- return ;
188
- }
189
- sinon . stub ( mockAuthInstance , '_getRecaptchaConfig' ) . returns ( {
190
- emailPasswordEnabled : false ,
191
- siteKey : 'mock_site_key'
192
- } ) ;
193
- mockActionMethod . onFirstCall ( ) . rejects ( {
194
- code : 'auth/MISSING_RECAPTCHA_TOKEN'
195
- } ) ;
196
- mockActionMethod . onSecondCall ( ) . resolves ( 'success-after-recaptcha' ) ;
197
-
198
- const result = await handleRecaptchaFlow (
199
- mockAuthInstance ,
200
- mockRequest ,
201
- RecaptchaActionName . GET_OOB_CODE ,
202
- mockActionMethod
203
- ) ;
204
-
205
- expect ( result ) . to . equal ( 'success-after-recaptcha' ) ;
206
- expect ( mockActionMethod ) . to . have . been . calledTwice ;
207
- } ) ;
208
- } ) ;
209
120
} ) ;
0 commit comments