mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
* first draft at an idea dependency graph * ignore existing errors * remove conflicting rule regarding internal platform logic in libs * review: allow components to import from platform
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { Overlay } from "@angular/cdk/overlay";
|
|
import { TestBed } from "@angular/core/testing";
|
|
|
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
|
import { DialogService } from "@bitwarden/components";
|
|
// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop.
|
|
// eslint-disable-next-line no-restricted-imports
|
|
import { openPasswordHistoryDialog } from "@bitwarden/vault";
|
|
|
|
import { VaultViewPasswordHistoryService } from "./view-password-history.service";
|
|
|
|
jest.mock("@bitwarden/vault", () => ({
|
|
openPasswordHistoryDialog: jest.fn(),
|
|
}));
|
|
|
|
describe("VaultViewPasswordHistoryService", () => {
|
|
let service: VaultViewPasswordHistoryService;
|
|
let dialogService: DialogService;
|
|
|
|
beforeEach(async () => {
|
|
const mockDialogService = {
|
|
open: jest.fn(),
|
|
};
|
|
|
|
await TestBed.configureTestingModule({
|
|
providers: [
|
|
VaultViewPasswordHistoryService,
|
|
{ provide: DialogService, useValue: mockDialogService },
|
|
Overlay,
|
|
],
|
|
}).compileComponents();
|
|
|
|
service = TestBed.inject(VaultViewPasswordHistoryService);
|
|
dialogService = TestBed.inject(DialogService);
|
|
});
|
|
|
|
describe("viewPasswordHistory", () => {
|
|
it("calls openPasswordHistoryDialog with the correct parameters", async () => {
|
|
const mockCipher = { id: "cipher-id" } as CipherView;
|
|
await service.viewPasswordHistory(mockCipher);
|
|
expect(openPasswordHistoryDialog).toHaveBeenCalledWith(dialogService, {
|
|
data: { cipher: mockCipher },
|
|
});
|
|
});
|
|
});
|
|
});
|