Skip to content

Commit

Permalink
Update the test
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrasinskis committed Sep 27, 2024
1 parent 3168035 commit ec5b441
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions frontend/src/tests/lib/services/icrc-index.services.spec.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit ec5b441

Please sign in to comment.