-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update recaptcha_enterprise_verifier.test.ts
- Loading branch information
renkelvin
committed
Oct 14, 2023
1 parent
eff15ef
commit 0682586
Showing
1 changed file
with
35 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,30 +140,48 @@ describe('platform_browser/recaptcha/recaptcha_enterprise_verifier', () => { | |
sinon.restore(); | ||
}); | ||
|
||
it('should handle recaptcha when emailPasswordEnabled is true', async () => { | ||
it('should call actionMethod with request if emailPasswordEnabled is true', async () => { | ||
if (typeof window === 'undefined') { | ||
return; | ||
} | ||
sinon.stub(mockAuthInstance, '_getRecaptchaConfig').returns({ | ||
emailPasswordEnabled: true, | ||
siteKey: 'mock_site_key' | ||
}); | ||
mockActionMethod.resolves('success'); | ||
mockEndpointWithParams(Endpoint.SEND_OOB_CODE, mockRequest, { | ||
email: '[email protected]' | ||
}); | ||
|
||
const result = await handleRecaptchaFlow( | ||
|
||
const authInstance = { | ||
_getRecaptchaConfig: () => ({ emailPasswordEnabled: true }) | ||
}; | ||
const request = { foo: 'bar' }; | ||
const actionName = RecaptchaActionName.SIGN_IN_WITH_PASSWORD; | ||
const actionMethod = sinon.stub().resolves('testResponse'); | ||
const response = await handleRecaptchaFlow( | ||
mockAuthInstance, | ||
mockRequest, | ||
RecaptchaActionName.GET_OOB_CODE, | ||
mockActionMethod | ||
request, | ||
actionName, | ||
actionMethod | ||
); | ||
|
||
expect(result).to.equal('success'); | ||
expect(mockActionMethod).to.have.been.calledOnce; | ||
expect(actionMethod).to.have.been.calledWith(authInstance, request); | ||
expect(response).to.equal('testResponse'); | ||
}); | ||
|
||
// it('should handle recaptcha when emailPasswordEnabled is true', async () => { | ||
// if (typeof window === 'undefined') { | ||
// return; | ||
// } | ||
// mockActionMethod.resolves('success'); | ||
// sinon.stub(mockAuthInstance, '_getRecaptchaConfig').returns({ | ||
// emailPasswordEnabled: true, | ||
// siteKey: 'mock_site_key' | ||
// }); | ||
|
||
// const result = await handleRecaptchaFlow( | ||
// mockAuthInstance, | ||
// mockRequest, | ||
// RecaptchaActionName.GET_OOB_CODE, | ||
// mockActionMethod | ||
// ); | ||
|
||
// expect(result).to.equal('success'); | ||
// expect(mockActionMethod).to.have.been.calledOnce; | ||
// }); | ||
|
||
// it('should handle action without recaptcha when emailPasswordEnabled is false and no error', async () => { | ||
// if (typeof window === 'undefined') { | ||
// return; | ||
|