Skip to content

Commit e52ee10

Browse files
committed
chore: Cleanup tests
1 parent 56afee3 commit e52ee10

23 files changed

+11
-82
lines changed

packages/angular/src/lib/auth/forms/email-link-auth-form.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ describe("<fui-email-link-auth-form />", () => {
309309
],
310310
});
311311

312-
// Wait for the async completeSignIn to be called
313312
await waitFor(() => {
314313
expect(mockCompleteEmailLinkSignIn).toHaveBeenCalledWith(
315314
expect.objectContaining({

packages/angular/src/lib/auth/forms/forgot-password-auth-form.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,11 @@ describe("<fui-forgot-password-auth-form />", () => {
277277
component.form.setFieldValue("email", "nonexistent@example.com");
278278
fixture.detectChanges();
279279

280-
// Trigger form submission
281280
await component.form.handleSubmit();
282281
await fixture.whenStable();
283282
fixture.detectChanges();
284283

285284
expect(component.emailSent()).toBe(false);
286-
// The error should be in the form state
287285
expect(component.form.state.errors.length).toBeGreaterThan(0);
288286
});
289287

@@ -309,13 +307,11 @@ describe("<fui-forgot-password-auth-form />", () => {
309307
component.form.setFieldValue("email", "test@example.com");
310308
fixture.detectChanges();
311309

312-
// Trigger form submission
313310
await component.form.handleSubmit();
314311
await fixture.whenStable();
315312
fixture.detectChanges();
316313

317314
expect(component.emailSent()).toBe(false);
318-
// The error should be in the form state
319315
expect(component.form.state.errors.length).toBeGreaterThan(0);
320316
});
321317

@@ -344,7 +340,6 @@ describe("<fui-forgot-password-auth-form />", () => {
344340
component.form.setFieldValue("email", "test@example.com");
345341
fixture.detectChanges();
346342

347-
// Should have no errors now
348343
expect(component.form.state.errors).toHaveLength(0);
349344
});
350345
});

packages/angular/src/lib/auth/forms/mfa/sms-multi-factor-assertion-form.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ describe("<fui-sms-multi-factor-assertion-form>", () => {
7171
});
7272
});
7373

74-
// Mock FirebaseUI Core functions
7574
verifyPhoneNumber.mockResolvedValue("test-verification-id");
7675
signInWithMultiFactorAssertion.mockResolvedValue({});
7776

78-
// Mock Firebase Auth classes
7977
const { PhoneAuthProvider, PhoneMultiFactorGenerator } = require("firebase/auth");
8078
PhoneAuthProvider.credential = jest.fn().mockReturnValue({});
8179
PhoneMultiFactorGenerator.assertion = jest.fn().mockReturnValue({});
@@ -107,20 +105,17 @@ describe("<fui-sms-multi-factor-assertion-form>", () => {
107105
phoneNumber: "+1234567890",
108106
};
109107

110-
const { fixture } = await render(SmsMultiFactorAssertionFormComponent, {
108+
await render(SmsMultiFactorAssertionFormComponent, {
111109
componentInputs: {
112110
hint: mockHint,
113111
},
114112
imports: [SmsMultiFactorAssertionFormComponent],
115113
});
116114

117-
// Initially shows phone form
118115
expect(screen.getByLabelText("Phone Number")).toBeInTheDocument();
119116

120-
// Submit the phone form
121117
fireEvent.click(screen.getByRole("button", { name: "Send Code" }));
122118

123-
// Wait for the form to switch
124119
await waitFor(() => {
125120
expect(screen.getByLabelText("Verification Code")).toBeInTheDocument();
126121
});
@@ -146,7 +141,6 @@ describe("<fui-sms-multi-factor-assertion-form>", () => {
146141
const onSuccessSpy = jest.fn();
147142
fixture.componentInstance.onSuccess.subscribe(onSuccessSpy);
148143

149-
// Submit phone form to get to verification form
150144
const phoneFormComponent = fixture.debugElement.query(
151145
(el) => el.componentInstance?.constructor?.name === "SmsMultiFactorAssertionPhoneFormComponent"
152146
)?.componentInstance;
@@ -160,7 +154,6 @@ describe("<fui-sms-multi-factor-assertion-form>", () => {
160154
expect(screen.getByLabelText("Verification Code")).toBeInTheDocument();
161155
});
162156

163-
// Fill in verification code and submit
164157
const verifyFormComponent = fixture.debugElement.query(
165158
(el) => el.componentInstance?.constructor?.name === "SmsMultiFactorAssertionVerifyFormComponent"
166159
)?.componentInstance;
@@ -169,6 +162,8 @@ describe("<fui-sms-multi-factor-assertion-form>", () => {
169162
verifyFormComponent.form.setFieldValue("verificationCode", "123456");
170163
verifyFormComponent.form.setFieldValue("verificationId", "test-verification-id");
171164
await verifyFormComponent.form.handleSubmit();
165+
} else {
166+
fail("Verify form component not found");
172167
}
173168

174169
await waitFor(() => {
@@ -211,7 +206,6 @@ describe("<fui-sms-multi-factor-assertion-phone-form>", () => {
211206
});
212207
});
213208

214-
// Mock FirebaseUI Core functions
215209
verifyPhoneNumber.mockResolvedValue("test-verification-id");
216210
});
217211

@@ -293,10 +287,8 @@ describe("<fui-sms-multi-factor-assertion-verify-form>", () => {
293287
});
294288
});
295289

296-
// Mock FirebaseUI Core functions
297290
signInWithMultiFactorAssertion.mockResolvedValue({});
298291

299-
// Mock Firebase Auth classes
300292
const { PhoneAuthProvider, PhoneMultiFactorGenerator } = require("firebase/auth");
301293
PhoneAuthProvider.credential = jest.fn().mockReturnValue({});
302294
PhoneMultiFactorGenerator.assertion = jest.fn().mockReturnValue({});
@@ -325,7 +317,6 @@ describe("<fui-sms-multi-factor-assertion-verify-form>", () => {
325317
const onSuccessSpy = jest.fn();
326318
fixture.componentInstance.onSuccess.subscribe(onSuccessSpy);
327319

328-
// Fill in verification code and submit
329320
const component = fixture.componentInstance;
330321
component.form.setFieldValue("verificationCode", "123456");
331322
component.form.setFieldValue("verificationId", "test-verification-id");

packages/angular/src/lib/auth/forms/mfa/sms-multi-factor-enrollment-form.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ describe("<fui-sms-multi-factor-enrollment-form />", () => {
5353
mockPhoneAuthProvider = PhoneAuthProvider;
5454
mockPhoneMultiFactorGenerator = PhoneMultiFactorGenerator;
5555

56-
// Mock provider functions
5756
injectTranslation.mockImplementation((category: string, key: string) => {
5857
const mockTranslations: Record<string, Record<string, string>> = {
5958
labels: {
@@ -328,7 +327,6 @@ describe("<fui-sms-multi-factor-enrollment-form />", () => {
328327
});
329328

330329
it("should throw error if user is not authenticated", async () => {
331-
// Override the injectUI mock for this test
332330
const { injectUI } = require("../../../tests/test-helpers");
333331
injectUI.mockImplementation(() => {
334332
return () => ({

packages/angular/src/lib/auth/forms/mfa/totp-multi-factor-assertion-form.spec.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
* limitations under the License.
1414
*/
1515

16-
import { render, screen, fireEvent, waitFor } from "@testing-library/angular";
17-
import { TotpMultiFactorGenerator } from "firebase/auth";
16+
import { render, screen } from "@testing-library/angular";
1817

1918
import { TotpMultiFactorAssertionFormComponent } from "./totp-multi-factor-assertion-form";
20-
2119
import { signInWithMultiFactorAssertion, FirebaseUIError } from "../../../tests/test-helpers";
2220

2321
describe("<fui-totp-multi-factor-assertion-form>", () => {
@@ -58,14 +56,11 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
5856
});
5957
});
6058

61-
// Mock FirebaseUI Core functions
6259
signInWithMultiFactorAssertion.mockResolvedValue({});
6360

64-
// Mock Firebase Auth classes
6561
TotpMultiFactorGenerator = require("firebase/auth").TotpMultiFactorGenerator;
6662
TotpMultiFactorGenerator.assertionForSignIn = jest.fn().mockReturnValue({});
6763

68-
// Clear all mocks before each test
6964
jest.clearAllMocks();
7065
});
7166

@@ -102,7 +97,7 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
10297
imports: [TotpMultiFactorAssertionFormComponent],
10398
});
10499

105-
// Check that the form input component has the placeholder attribute
100+
// Verify the verification code input field starts empty (no pre-filled value)
106101
const formInput = screen.getByDisplayValue("");
107102
expect(formInput).toBeInTheDocument();
108103
});
@@ -125,7 +120,6 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
125120
const onSuccessSpy = jest.fn();
126121
component.onSuccess.subscribe(onSuccessSpy);
127122

128-
// Set form values and submit directly
129123
component.form.setFieldValue("verificationCode", "123456");
130124
fixture.detectChanges();
131125

@@ -153,7 +147,6 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
153147

154148
const component = fixture.componentInstance;
155149

156-
// Set form values and submit directly
157150
component.form.setFieldValue("verificationCode", "123456");
158151
fixture.detectChanges();
159152

@@ -182,7 +175,6 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
182175

183176
const component = fixture.componentInstance;
184177

185-
// Set form values and submit directly
186178
component.form.setFieldValue("verificationCode", "123456");
187179
fixture.detectChanges();
188180

@@ -214,7 +206,6 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
214206

215207
const component = fixture.componentInstance;
216208

217-
// Set form values and submit directly
218209
component.form.setFieldValue("verificationCode", "123456");
219210
fixture.detectChanges();
220211

@@ -243,7 +234,6 @@ describe("<fui-totp-multi-factor-assertion-form>", () => {
243234

244235
const component = fixture.componentInstance;
245236

246-
// Set form values and submit directly
247237
component.form.setFieldValue("verificationCode", "123456");
248238
fixture.detectChanges();
249239

packages/angular/src/lib/auth/forms/mfa/totp-multi-factor-enrollment-form.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe("<fui-totp-multi-factor-enrollment-form />", () => {
4747
mockFirebaseUIError = FirebaseUIError;
4848
mockTotpMultiFactorGenerator = TotpMultiFactorGenerator;
4949

50-
// Mock provider functions
5150
injectTranslation.mockImplementation((category: string, key: string) => {
5251
const mockTranslations: Record<string, Record<string, string>> = {
5352
labels: {
@@ -302,7 +301,6 @@ describe("<fui-totp-multi-factor-enrollment-form />", () => {
302301
});
303302

304303
it("should throw error if user is not authenticated", async () => {
305-
// Override the injectUI mock for this test
306304
const { injectUI } = require("../../../tests/test-helpers");
307305
injectUI.mockImplementation(() => {
308306
return () => ({

packages/angular/src/lib/auth/forms/multi-factor-auth-assertion-form.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ describe("<fui-multi-factor-auth-assertion-form>", () => {
112112
});
113113

114114
it("switches to assertion form when selection button is clicked", async () => {
115-
// Override the inner components with mocks
116115
TestBed.overrideComponent(SmsMultiFactorAssertionFormComponent, {
117116
set: {
118117
template: '<div data-testid="sms-assertion-form">SMS Assertion Form</div>',

packages/angular/src/lib/auth/forms/multi-factor-auth-enrollment-form.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ describe("<fui-multi-factor-auth-enrollment-form />", () => {
6868
},
6969
});
7070

71-
// Should not show selection buttons
7271
expect(screen.queryByRole("button", { name: "SMS Verification" })).not.toBeInTheDocument();
7372
expect(screen.queryByRole("button", { name: "TOTP Verification" })).not.toBeInTheDocument();
7473

75-
// Should show SMS form directly
7674
expect(screen.getByLabelText("Display Name")).toBeInTheDocument();
7775
expect(screen.getByLabelText("Phone Number")).toBeInTheDocument();
7876
});
@@ -139,7 +137,6 @@ describe("<fui-multi-factor-auth-enrollment-form />", () => {
139137
const component = fixture.componentInstance;
140138
const enrollmentSpy = jest.spyOn(component.onEnrollment, "emit");
141139

142-
// Get the SMS form component and emit enrollment
143140
const smsFormComponent = fixture.debugElement.query(
144141
(el) => el.componentInstance instanceof SmsMultiFactorEnrollmentFormComponent
145142
)?.componentInstance as SmsMultiFactorEnrollmentFormComponent;
@@ -167,7 +164,6 @@ describe("<fui-multi-factor-auth-enrollment-form />", () => {
167164
const component = fixture.componentInstance;
168165
const enrollmentSpy = jest.spyOn(component.onEnrollment, "emit");
169166

170-
// Get the TOTP form component and emit enrollment
171167
const totpFormComponent = fixture.debugElement.query(
172168
(el) => el.componentInstance instanceof TotpMultiFactorEnrollmentFormComponent
173169
)?.componentInstance as TotpMultiFactorEnrollmentFormComponent;

packages/angular/src/lib/auth/forms/sign-up-auth-form.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ describe("<fui-sign-up-auth-form />", () => {
151151
const component = fixture.componentInstance;
152152
expect(component.form.getFieldValue("email")).toBe("");
153153
expect(component.form.getFieldValue("password")).toBe("");
154-
// displayName is undefined when hasBehavior returns false
155154
expect(component.form.getFieldValue("displayName")).toBeUndefined();
156155
});
157156

packages/angular/src/lib/auth/oauth/apple-sign-in-button.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { Component } from "@angular/core";
1919

2020
import { AppleSignInButtonComponent } from "./apple-sign-in-button";
2121

22-
// Mocks are handled by jest.config.ts moduleNameMapper and test-helpers.ts
23-
2422
@Component({
2523
template: `<fui-apple-sign-in-button></fui-apple-sign-in-button>`,
2624
standalone: true,

0 commit comments

Comments
 (0)