Skip to content

Commit e834c72

Browse files
author
renkelvin
committed
format
1 parent 39e3fa2 commit e834c72

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

packages/auth/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.test.ts

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -125,78 +125,78 @@ describe('platform_browser/recaptcha/recaptcha_enterprise_verifier', () => {
125125
});
126126
});
127127

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+
});
132138

133-
beforeEach(async () => {
134-
mockAuthInstance = await testAuth();
135-
mockRequest = {};
136-
mockActionMethod = sinon.stub();
137-
});
139+
afterEach(() => {
140+
sinon.restore();
141+
});
138142

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+
);
142156

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
147160
});
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-
});
161161

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+
);
168175

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+
});
175179

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+
);
179196

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
187200
});
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
200201
});
201202
});
202-
});

0 commit comments

Comments
 (0)