Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jprusik committed Nov 13, 2024
1 parent 8ea5b48 commit 6dc73b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BehaviorSubject, of } from "rxjs";

import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
Expand All @@ -19,6 +20,7 @@ import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
import { ToastService } from "@bitwarden/components";
import { PasswordRepromptService } from "@bitwarden/vault";

import { InlineMenuFieldQualificationService } from "../../../../../browser/src/autofill/services/inline-menu-field-qualification.service";
import {
AutoFillOptions,
AutofillService,
Expand Down Expand Up @@ -46,13 +48,21 @@ describe("VaultPopupAutofillService", () => {
const mockPasswordRepromptService = mock<PasswordRepromptService>();
const mockCipherService = mock<CipherService>();
const mockMessagingService = mock<MessagingService>();
const mockInlineMenuFieldQualificationService = mock<InlineMenuFieldQualificationService>();
const mockLogService = mock<LogService>();

const mockUserId = Utils.newGuid() as UserId;
const accountService: FakeAccountService = mockAccountServiceWith(mockUserId);

beforeEach(() => {
jest.spyOn(BrowserPopupUtils, "inPopout").mockReturnValue(false);
jest.spyOn(BrowserApi, "getTabFromCurrentWindow").mockResolvedValue(mockCurrentTab);
jest
.spyOn(mockInlineMenuFieldQualificationService, "isFieldForCreditCardForm")
.mockReturnValue(true);
jest
.spyOn(mockInlineMenuFieldQualificationService, "isFieldForIdentityForm")
.mockReturnValue(true);

mockAutofillService.collectPageDetailsFromTab$.mockReturnValue(new BehaviorSubject([]));

Expand All @@ -70,6 +80,14 @@ describe("VaultPopupAutofillService", () => {
provide: AccountService,
useValue: accountService,
},
{
provide: InlineMenuFieldQualificationService,
useValue: mockInlineMenuFieldQualificationService,
},
{
provide: LogService,
useValue: mockLogService,
},
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { VaultSettingsService } from "@bitwarden/common/vault/abstractions/vault
import { CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";

import { InlineMenuFieldQualificationService } from "../../../../../browser/src/autofill/services/inline-menu-field-qualification.service";
import { BrowserApi } from "../../../platform/browser/browser-api";

import { VaultPopupAutofillService } from "./vault-popup-autofill.service";
Expand All @@ -39,6 +40,7 @@ describe("VaultPopupItemsService", () => {
const collectionService = mock<CollectionService>();
const vaultAutofillServiceMock = mock<VaultPopupAutofillService>();
const syncServiceMock = mock<SyncService>();
const inlineMenuFieldQualificationServiceMock = mock<InlineMenuFieldQualificationService>();

beforeEach(() => {
allCiphers = cipherFactory(10);
Expand Down Expand Up @@ -78,6 +80,11 @@ describe("VaultPopupItemsService", () => {
url: "https://example.com",
} as chrome.tabs.Tab);

vaultAutofillServiceMock.nonLoginCipherTypesOnPage$ = new BehaviorSubject({
[CipherType.Card]: true,
[CipherType.Identity]: true,
});

mockOrg = {
id: "org1",
name: "Organization 1",
Expand Down Expand Up @@ -105,6 +112,10 @@ describe("VaultPopupItemsService", () => {
{ provide: CollectionService, useValue: collectionService },
{ provide: VaultPopupAutofillService, useValue: vaultAutofillServiceMock },
{ provide: SyncService, useValue: syncServiceMock },
{
provide: InlineMenuFieldQualificationService,
useValue: inlineMenuFieldQualificationServiceMock,
},
],
});

Expand Down

0 comments on commit 6dc73b8

Please sign in to comment.