1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-06 23:51:28 +01:00

test fixes

This commit is contained in:
--global 2025-01-17 18:47:59 -05:00
parent 08be4a1886
commit 13089536b3

View File

@ -7,10 +7,14 @@ import { Subject, of } from "rxjs";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { StateProvider } from "@bitwarden/common/platform/state";
import { FakeAccountService, mockAccountServiceWith } from "@bitwarden/common/spec";
import { UserId } from "@bitwarden/common/types/guid";
import { CipherType } from "@bitwarden/common/vault/enums/cipher-type";
import { VaultOnboardingMessages } from "@bitwarden/common/vault/enums/vault-onboarding.enum";
@ -29,6 +33,7 @@ describe("VaultOnboardingComponent", () => {
let setInstallExtLinkSpy: any;
let individualVaultPolicyCheckSpy: any;
let mockConfigService: MockProxy<ConfigService>;
const mockAccountService: FakeAccountService = mockAccountServiceWith(Utils.newGuid() as UserId);
beforeEach(() => {
mockPolicyService = mock<PolicyService>();
@ -39,7 +44,7 @@ describe("VaultOnboardingComponent", () => {
};
mockVaultOnboardingService = mock<VaultOnboardingServiceAbstraction>();
mockStateProvider = {
getActive: jest.fn().mockReturnValue(
getUser: jest.fn().mockReturnValue(
of({
createAccount: true,
importData: false,
@ -61,6 +66,7 @@ describe("VaultOnboardingComponent", () => {
{ provide: ApiService, useValue: mockApiService },
{ provide: StateProvider, useValue: mockStateProvider },
{ provide: ConfigService, useValue: mockConfigService },
{ provide: AccountService, useValue: mockAccountService },
],
}).compileComponents();
fixture = TestBed.createComponent(VaultOnboardingComponent);
@ -71,11 +77,15 @@ describe("VaultOnboardingComponent", () => {
.mockReturnValue(undefined);
jest.spyOn(component, "checkCreationDate").mockReturnValue(null);
jest.spyOn(window, "postMessage").mockImplementation(jest.fn());
(component as any).vaultOnboardingService.vaultOnboardingState$ = of({
createAccount: true,
importData: false,
installExtension: false,
});
(component as any).vaultOnboardingService.vaultOnboardingState$ = jest
.fn()
.mockImplementation(() => {
return of({
createAccount: true,
importData: false,
installExtension: false,
});
});
});
it("should create", () => {
@ -169,12 +179,15 @@ describe("VaultOnboardingComponent", () => {
.spyOn((component as any).vaultOnboardingService, "setVaultOnboardingTasks")
.mockReturnValue(Promise.resolve());
(component as any).vaultOnboardingService.vaultOnboardingState$ = of({
createAccount: true,
importData: false,
installExtension: false,
});
(component as any).vaultOnboardingService.vaultOnboardingState$ = jest
.fn()
.mockImplementation(() => {
return of({
createAccount: true,
importData: false,
installExtension: false,
});
});
const eventData = { data: { command: VaultOnboardingMessages.HasBwInstalled } };
(component as any).showOnboarding = true;