From ec5b441e625ee1555a8b1d990237429081a0120c Mon Sep 17 00:00:00 2001 From: Max Strasinsky Date: Fri, 27 Sep 2024 16:36:11 +0200 Subject: [PATCH] Update the test --- .../tests/lib/services/icrc-index.services.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/tests/lib/services/icrc-index.services.spec.ts b/frontend/src/tests/lib/services/icrc-index.services.spec.ts index d5b8af8ae28..90bd8aa8287 100644 --- a/frontend/src/tests/lib/services/icrc-index.services.spec.ts +++ b/frontend/src/tests/lib/services/icrc-index.services.spec.ts @@ -1,7 +1,7 @@ import * as icrcIndexApi from "$lib/api/icrc-index.api"; import { matchLedgerIndexPair } from "$lib/services/icrc-index.services"; import * as toastsStore from "$lib/stores/toasts.store"; -import { resetIdentity } from "$tests/mocks/auth.store.mock"; +import { mockIdentity, resetIdentity } from "$tests/mocks/auth.store.mock"; import { principal } from "$tests/mocks/sns-projects.mock"; describe("icrc-index.services", () => { @@ -16,14 +16,23 @@ describe("icrc-index.services", () => { }); it("should return true when the ledger canister IDs match", async () => { - vi.spyOn(icrcIndexApi, "getLedgerId").mockResolvedValue(ledgerCanisterId); + const spyOnGetLedgerId = vi + .spyOn(icrcIndexApi, "getLedgerId") + .mockResolvedValue(ledgerCanisterId); + expect(spyOnGetLedgerId).toBeCalledTimes(0); const result = await matchLedgerIndexPair({ ledgerCanisterId, indexCanisterId, }); expect(result).toEqual(true); + expect(spyOnGetLedgerId).toBeCalledTimes(1); + expect(spyOnGetLedgerId).toBeCalledWith({ + certified: true, + identity: mockIdentity, + indexCanisterId, + }); }); it("should return false when the ledger canister IDs don't match", async () => {