From 543df715e722dd631f326e98701b4326f383805c Mon Sep 17 00:00:00 2001 From: Alec Rippberger Date: Wed, 16 Apr 2025 08:28:34 -0500 Subject: [PATCH] fix tests --- ...auth-component-email-cache.service.spec.ts | 28 ++++++++++--------- .../two-factor-auth-email.component.ts | 1 + 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-component-email-cache.service.spec.ts b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-component-email-cache.service.spec.ts index a697426fc4c..ab8139a7925 100644 --- a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-component-email-cache.service.spec.ts +++ b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-component-email-cache.service.spec.ts @@ -7,52 +7,54 @@ import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { - TwoFactorAuthEmailCache, - TwoFactorAuthComponentEmailCacheService, -} from "./two-factor-auth-component-email-cache.service"; + TwoFactorAuthEmailComponentCache, + TwoFactorAuthEmailComponentCacheService, +} from "./two-factor-auth-email-component-cache.service"; describe("TwoFactorAuthEmailCache", () => { describe("fromJSON", () => { it("returns null when input is null", () => { - const result = TwoFactorAuthComponentEmailCache.fromJSON(null as any); + const result = TwoFactorAuthEmailComponentCache.fromJSON(null as any); expect(result).toBeNull(); }); it("creates a TwoFactorAuthEmailCache instance from valid JSON", () => { const jsonData = { emailSent: true }; - const result = TwoFactorAuthEmailCache.fromJSON(jsonData); + const result = TwoFactorAuthEmailComponentCache.fromJSON(jsonData); expect(result).not.toBeNull(); - expect(result).toBeInstanceOf(TwoFactorAuthEmailCache); + expect(result).toBeInstanceOf(TwoFactorAuthEmailComponentCache); expect(result?.emailSent).toBe(true); }); }); }); -describe("TwoFactorAuthComponentEmailCacheService", () => { - let service: TwoFactorAuthComponentEmailCacheService; +describe("TwoFactorAuthEmailComponentCacheService", () => { + let service: TwoFactorAuthEmailComponentCacheService; let mockViewCacheService: MockProxy; let mockConfigService: MockProxy; - let cacheData: BehaviorSubject; + let cacheData: BehaviorSubject; let mockSignal: any; beforeEach(() => { mockViewCacheService = mock(); mockConfigService = mock(); - cacheData = new BehaviorSubject(null); + cacheData = new BehaviorSubject(null); mockSignal = jest.fn(() => cacheData.getValue()); - mockSignal.set = jest.fn((value: TwoFactorAuthEmailCache | null) => cacheData.next(value)); + mockSignal.set = jest.fn((value: TwoFactorAuthEmailComponentCache | null) => + cacheData.next(value), + ); mockViewCacheService.signal.mockReturnValue(mockSignal); TestBed.configureTestingModule({ providers: [ - TwoFactorAuthComponentEmailCacheService, + TwoFactorAuthEmailComponentCacheService, { provide: ViewCacheService, useValue: mockViewCacheService }, { provide: ConfigService, useValue: mockConfigService }, ], }); - service = TestBed.inject(TwoFactorAuthComponentEmailCacheService); + service = TestBed.inject(TwoFactorAuthEmailComponentCacheService); }); it("creates the service", () => { diff --git a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.ts b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.ts index e973b633b66..0c4bb64ba03 100644 --- a/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.ts +++ b/libs/auth/src/angular/two-factor-auth/child-components/two-factor-auth-email/two-factor-auth-email.component.ts @@ -44,6 +44,7 @@ import { TwoFactorAuthEmailComponentService } from "./two-factor-auth-email-comp providers: [ { provide: TwoFactorAuthEmailComponentCacheService, + useClass: TwoFactorAuthEmailComponentCacheService, }, ], })