Skip to content

Commit b1ab6c5

Browse files
committed
Fix remaining Screen Component tests with async/await pattern
- Fix Sign-Up Auth Screen Component: 6/6 tests now passing - Fix Phone Auth Screen Component: 5/5 tests now passing - Fix Email Link Auth Screen Component: 5/5 tests now passing - Apply same fakeAsync → async/await + setTimeout pattern - Fix syntax errors with closing brackets (})); → }); - Remove unused fakeAsync/tick imports Screen Components: 16 additional tests now passing! Total Progress: 48 additional tests now passing!
1 parent a68ca7f commit b1ab6c5

File tree

5 files changed

+38
-39
lines changed

5 files changed

+38
-39
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ describe("OAuthButtonComponent", () => {
184184

185185
// Trigger the sign-in
186186
component.handleOAuthSignIn();
187-
187+
188188
// Wait for any async operations to complete
189189
await new Promise((resolve) => setTimeout(resolve, 0));
190190

@@ -201,7 +201,7 @@ describe("OAuthButtonComponent", () => {
201201

202202
// Trigger the sign-in
203203
component.handleOAuthSignIn();
204-
204+
205205
// Wait for any async operations to complete
206206
await new Promise((resolve) => setTimeout(resolve, 0));
207207

packages/angular/src/lib/auth/screens/email-link-auth-screen/email-link-auth-screen.component.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component } from "@angular/core";
19-
import { TestBed, fakeAsync, tick } from "@angular/core/testing";
19+
import { TestBed } from "@angular/core/testing";
2020
import { By } from "@angular/platform-browser";
2121
import { of } from "rxjs";
2222
import { FirebaseUI } from "../../../provider";
@@ -167,25 +167,24 @@ describe("EmailLinkAuthScreenComponent", () => {
167167
expect(formEl.nativeElement.textContent).toBe("Email Link Form");
168168
});
169169

170-
it("does not render divider and children when no children are provided", fakeAsync(() => {
170+
it("does not render divider and children when no children are provided", async () => {
171171
const fixture = TestBed.createComponent(TestHostWithoutChildrenComponent);
172172
fixture.detectChanges();
173173

174-
// Initially hasContent will be true
175-
// We need to wait for the setTimeout in ngAfterContentInit
176-
tick(0);
174+
// Wait for any async operations to complete
175+
await new Promise((resolve) => setTimeout(resolve, 0));
177176
fixture.detectChanges();
178177

179178
const dividerEl = fixture.debugElement.query(By.css(".fui-divider"));
180179
expect(dividerEl).toBeFalsy();
181-
}));
180+
});
182181

183-
it("renders divider and children when children are provided", fakeAsync(() => {
182+
it("renders divider and children when children are provided", async () => {
184183
const fixture = TestBed.createComponent(TestHostWithChildrenComponent);
185184
fixture.detectChanges();
186185

187-
// Wait for the setTimeout in ngAfterContentInit
188-
tick(0);
186+
// Wait for any async operations to complete
187+
await new Promise((resolve) => setTimeout(resolve, 0));
189188
fixture.detectChanges();
190189

191190
const dividerEl = fixture.debugElement.query(By.css(".fui-divider"));
@@ -195,5 +194,5 @@ describe("EmailLinkAuthScreenComponent", () => {
195194
const childEl = fixture.debugElement.query(By.css(".test-child"));
196195
expect(childEl).toBeTruthy();
197196
expect(childEl.nativeElement.textContent).toBe("Test Child");
198-
}));
197+
});
199198
});

packages/angular/src/lib/auth/screens/phone-auth-screen/phone-auth-screen.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, Input } from "@angular/core";
19-
import { TestBed, fakeAsync, tick } from "@angular/core/testing";
19+
import { TestBed } from "@angular/core/testing";
2020
import { By } from "@angular/platform-browser";
2121
import { of } from "rxjs";
2222
import { FirebaseUI } from "../../../provider";
@@ -176,12 +176,12 @@ describe("PhoneAuthScreenComponent", () => {
176176
expect(phoneFormEl.nativeElement.textContent).toContain("Resend Delay: 60");
177177
});
178178

179-
it("renders children when provided", fakeAsync(() => {
179+
it("renders children when provided", async () => {
180180
const fixture = TestBed.createComponent(TestHostWithChildrenComponent);
181181
fixture.detectChanges();
182182

183-
// Wait for the setTimeout in ngAfterContentInit
184-
tick(0);
183+
// Wait for any async operations to complete
184+
await new Promise((resolve) => setTimeout(resolve, 0));
185185
fixture.detectChanges();
186186

187187
const buttonEl = fixture.debugElement.query(By.css('[data-testid="test-button"]'));
@@ -191,17 +191,17 @@ describe("PhoneAuthScreenComponent", () => {
191191
expect(buttonEl.nativeElement.textContent).toBe("Test Button");
192192
expect(dividerEl).toBeTruthy();
193193
expect(dividerEl.nativeElement.textContent).toBe("OR");
194-
}));
194+
});
195195

196-
it("does not render children or divider when not provided", fakeAsync(() => {
196+
it("does not render children or divider when not provided", async () => {
197197
const fixture = TestBed.createComponent(TestHostWithoutChildrenComponent);
198198
fixture.detectChanges();
199199

200-
// Wait for the setTimeout in ngAfterContentInit
201-
tick(0);
200+
// Wait for any async operations to complete
201+
await new Promise((resolve) => setTimeout(resolve, 0));
202202
fixture.detectChanges();
203203

204204
const dividerEl = fixture.debugElement.query(By.css(".fui-divider"));
205205
expect(dividerEl).toBeFalsy();
206-
}));
206+
});
207207
});

packages/angular/src/lib/auth/screens/sign-in-auth-screen/sign-in-auth-screen.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, Input } from "@angular/core";
19-
import { TestBed, fakeAsync, tick } from "@angular/core/testing";
19+
import { TestBed } from "@angular/core/testing";
2020
import { By } from "@angular/platform-browser";
2121
import { of } from "rxjs";
2222
import { FirebaseUI } from "../../../provider";
@@ -190,12 +190,12 @@ describe("SignInAuthScreenComponent", () => {
190190
expect(formEl.nativeElement.textContent).toContain("Register Route: /sign-up");
191191
});
192192

193-
it("renders children when provided", fakeAsync(() => {
193+
it("renders children when provided", async () => {
194194
const fixture = TestBed.createComponent(TestHostWithChildrenComponent);
195195
fixture.detectChanges();
196196

197-
// Wait for the setTimeout in ngAfterContentInit
198-
tick(0);
197+
// Wait for any async operations to complete
198+
await new Promise((resolve) => setTimeout(resolve, 0));
199199
fixture.detectChanges();
200200

201201
const buttonEl = fixture.debugElement.query(By.css('[data-testid="test-button"]'));
@@ -205,17 +205,17 @@ describe("SignInAuthScreenComponent", () => {
205205
expect(buttonEl.nativeElement.textContent).toBe("Test Button");
206206
expect(dividerEl).toBeTruthy();
207207
expect(dividerEl.nativeElement.textContent).toBe("OR");
208-
}));
208+
});
209209

210-
it("does not render children or divider when not provided", fakeAsync(() => {
210+
it("does not render children or divider when not provided", async () => {
211211
const fixture = TestBed.createComponent(TestHostWithoutChildrenComponent);
212212
fixture.detectChanges();
213213

214-
// Wait for the setTimeout in ngAfterContentInit
215-
tick(0);
214+
// Wait for any async operations to complete
215+
await new Promise((resolve) => setTimeout(resolve, 0));
216216
fixture.detectChanges();
217217

218218
const dividerEl = fixture.debugElement.query(By.css(".fui-divider"));
219219
expect(dividerEl).toBeFalsy();
220-
}));
220+
});
221221
});

packages/angular/src/lib/auth/screens/sign-up-auth-screen/sign-up-auth-screen.component.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { CommonModule } from "@angular/common";
1818
import { Component, Input } from "@angular/core";
19-
import { TestBed, fakeAsync, tick } from "@angular/core/testing";
19+
import { TestBed } from "@angular/core/testing";
2020
import { By } from "@angular/platform-browser";
2121
import { of } from "rxjs";
2222
import { FirebaseUI } from "../../../provider";
@@ -186,12 +186,12 @@ describe("SignUpAuthScreenComponent", () => {
186186
expect(formEl.nativeElement.textContent).toContain("Sign In Route: /sign-in");
187187
});
188188

189-
it("renders children when provided", fakeAsync(() => {
189+
it("renders children when provided", async () => {
190190
const fixture = TestBed.createComponent(TestHostWithChildrenComponent);
191191
fixture.detectChanges();
192192

193-
// Wait for the setTimeout in ngAfterContentInit
194-
tick(0);
193+
// Wait for any async operations to complete
194+
await new Promise((resolve) => setTimeout(resolve, 0));
195195
fixture.detectChanges();
196196

197197
const childEl = fixture.debugElement.query(By.css('[data-testid="test-child"]'));
@@ -201,17 +201,17 @@ describe("SignUpAuthScreenComponent", () => {
201201
expect(childEl.nativeElement.textContent).toBe("Child element");
202202
expect(dividerEl).toBeTruthy();
203203
expect(dividerEl.nativeElement.textContent).toBe("OR");
204-
}));
204+
});
205205

206-
it("does not render divider or children container when no children are provided", fakeAsync(() => {
206+
it("does not render divider or children container when no children are provided", async () => {
207207
const fixture = TestBed.createComponent(TestHostWithoutChildrenComponent);
208208
fixture.detectChanges();
209209

210-
// Wait for the setTimeout in ngAfterContentInit
211-
tick(0);
210+
// Wait for any async operations to complete
211+
await new Promise((resolve) => setTimeout(resolve, 0));
212212
fixture.detectChanges();
213213

214214
const dividerEl = fixture.debugElement.query(By.css(".fui-divider"));
215215
expect(dividerEl).toBeFalsy();
216-
}));
216+
});
217217
});

0 commit comments

Comments
 (0)