Skip to content

Commit f7aa0dd

Browse files
committed
fix(angular): patched unit tests to match core updates
1 parent 272ea22 commit f7aa0dd

File tree

5 files changed

+240
-224
lines changed

5 files changed

+240
-224
lines changed

packages/angular/projects/firebaseui-angular/src/lib/auth/forms/phone-form/phone-form.component.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
PhoneNumberFormComponent,
2121
VerificationFormComponent,
2222
} from './phone-form.component';
23+
import { mockAuth } from '../../../testing/test-helpers';
2324

2425
// Mock Firebase UI Core functions
2526
const mockFuiSignInWithPhoneNumber = jasmine
@@ -28,7 +29,7 @@ const mockFuiSignInWithPhoneNumber = jasmine
2829
Promise.resolve({
2930
confirm: jasmine.createSpy('confirm').and.returnValue(Promise.resolve()),
3031
verificationId: 'mock-verification-id',
31-
} as ConfirmationResult)
32+
} as ConfirmationResult),
3233
);
3334

3435
const mockFuiConfirmPhoneNumber = jasmine
@@ -104,6 +105,7 @@ class MockCountrySelectorComponent {
104105
class MockFirebaseUi {
105106
config() {
106107
return of({
108+
getAuth: () => mockAuth,
107109
recaptchaMode: 'normal',
108110
translations: {},
109111
});
@@ -120,11 +122,11 @@ class TestPhoneFormComponent extends PhoneFormComponent {
120122
initRecaptcha() {
121123
const mockRecaptchaVerifier = jasmine.createSpyObj<RecaptchaVerifier>(
122124
'RecaptchaVerifier',
123-
['render', 'clear', 'verify']
125+
['render', 'clear', 'verify'],
124126
);
125127
mockRecaptchaVerifier.render.and.returnValue(Promise.resolve(1));
126128
mockRecaptchaVerifier.verify.and.returnValue(
127-
Promise.resolve('verification-token')
129+
Promise.resolve('verification-token'),
128130
);
129131

130132
this.recaptchaVerifier = mockRecaptchaVerifier;
@@ -163,7 +165,7 @@ class TestPhoneFormComponent extends PhoneFormComponent {
163165
{
164166
translations: {},
165167
language: 'en',
166-
}
168+
},
167169
);
168170

169171
this.confirmationResult = result;
@@ -223,7 +225,7 @@ class TestPhoneFormComponent extends PhoneFormComponent {
223225
{
224226
translations: {},
225227
language: 'en',
226-
}
228+
},
227229
);
228230

229231
this.confirmationResult = result;
@@ -244,11 +246,11 @@ class TestPhoneNumberFormComponent extends PhoneNumberFormComponent {
244246
override initRecaptcha() {
245247
const mockRecaptchaVerifier = jasmine.createSpyObj<RecaptchaVerifier>(
246248
'RecaptchaVerifier',
247-
['render', 'clear', 'verify']
249+
['render', 'clear', 'verify'],
248250
);
249251
mockRecaptchaVerifier.render.and.returnValue(Promise.resolve(1));
250252
mockRecaptchaVerifier.verify.and.returnValue(
251-
Promise.resolve('verification-token')
253+
Promise.resolve('verification-token'),
252254
);
253255

254256
this.recaptchaVerifier = mockRecaptchaVerifier;
@@ -273,11 +275,11 @@ describe('PhoneFormComponent', () => {
273275

274276
mockRecaptchaVerifier = jasmine.createSpyObj<RecaptchaVerifier>(
275277
'RecaptchaVerifier',
276-
['render', 'clear', 'verify']
278+
['render', 'clear', 'verify'],
277279
);
278280
mockRecaptchaVerifier.render.and.returnValue(Promise.resolve(1));
279281
mockRecaptchaVerifier.verify.and.returnValue(
280-
Promise.resolve('verification-token')
282+
Promise.resolve('verification-token'),
281283
);
282284

283285
// Create mock schema for phone validation
@@ -363,7 +365,7 @@ describe('PhoneFormComponent', () => {
363365
confirm: jasmine
364366
.createSpy('confirm')
365367
.and.returnValue(Promise.resolve()),
366-
})
368+
}),
367369
),
368370
signInWithCredential: jasmine
369371
.createSpy('signInWithCredential')
@@ -398,7 +400,7 @@ describe('PhoneFormComponent', () => {
398400

399401
// Mock DOM methods
400402
spyOn(document, 'querySelector').and.returnValue(
401-
document.createElement('div')
403+
document.createElement('div'),
402404
);
403405

404406
// Directly replace timer with mock implementation

packages/angular/projects/firebaseui-angular/src/lib/auth/oauth/oauth-button.component.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class TestOAuthButtonComponent extends OAuthButtonComponent {
7575
try {
7676
const config = await firstValueFrom(this['ui'].config());
7777

78-
await mockFuiSignInWithOAuth(config.getAuth(), this.provider);
78+
await mockFuiSignInWithOAuth(config, this.provider);
7979
} catch (error) {
8080
if (error instanceof FirebaseUIError) {
8181
this.error = error.message;
@@ -85,7 +85,7 @@ class TestOAuthButtonComponent extends OAuthButtonComponent {
8585

8686
try {
8787
const errorMessage = await firstValueFrom(
88-
this['ui'].translation('errors', 'unknownError')
88+
this['ui'].translation('errors', 'unknownError'),
8989
);
9090
this.error = errorMessage ?? 'Unknown error';
9191
} catch {
@@ -141,7 +141,7 @@ describe('OAuthButtonComponent', () => {
141141
component.provider = undefined as unknown as AuthProvider;
142142
component.ngOnInit();
143143
expect(console.error).toHaveBeenCalledWith(
144-
'Provider is required for OAuthButtonComponent'
144+
'Provider is required for OAuthButtonComponent',
145145
);
146146
});
147147

@@ -160,14 +160,13 @@ describe('OAuthButtonComponent', () => {
160160

161161
// Check if the mock function was called with the correct arguments
162162
expect(mockFuiSignInWithOAuth).toHaveBeenCalledWith(
163-
mockAuth,
164-
mockProvider,
165163
jasmine.objectContaining({
166164
language: 'en',
167165
translations: {},
168166
enableAutoUpgradeAnonymous: false,
169167
enableHandleExistingCredential: false,
170-
})
168+
}),
169+
mockProvider,
171170
);
172171
}));
173172

0 commit comments

Comments
 (0)