Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dskloetd committed Nov 7, 2024
1 parent a14ccf6 commit fe6ac38
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/src/lib/services/public/sns.services.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SnsSwapLifecycle } from "@dfinity/sns";
import { snsAggregatorApiService } from "$lib/api-services/sns-aggregator.api-service";
import { queryProposals } from "$lib/api/proposals.api";
import { buildAndStoreWrapper } from "$lib/api/sns-wrapper.api";
Expand All @@ -11,6 +10,7 @@ import { isLastCall } from "$lib/utils/env.utils";
import { toToastError } from "$lib/utils/error.utils";
import { ProposalStatus, Topic, type ProposalInfo } from "@dfinity/nns";
import { Principal } from "@dfinity/principal";
import { SnsSwapLifecycle } from "@dfinity/sns";
import { getCurrentIdentity } from "../auth.services";

export const loadSnsProjects = async (): Promise<void> => {
Expand Down
29 changes: 20 additions & 9 deletions frontend/src/tests/lib/services/public/sns.services.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { SnsSwapLifecycle } from "@dfinity/sns";
import { clearSnsAggregatorCache } from "$lib/api-services/sns-aggregator.api-service";
import * as agent from "$lib/api/agent.api";
import * as aggregatorApi from "$lib/api/sns-aggregator.api";
import { clearWrapperCache, wrapper, wrappers as getWrappers} from "$lib/api/sns-wrapper.api";
import {
clearWrapperCache,
wrappers as getWrappers,
wrapper,
} from "$lib/api/sns-wrapper.api";
import { snsFunctionsStore } from "$lib/derived/sns-functions.derived";
import { snsTotalTokenSupplyStore } from "$lib/derived/sns-total-token-supply.derived";
import { loadSnsProjects } from "$lib/services/public/sns.services";
Expand All @@ -27,6 +30,7 @@ import {
} from "$tests/mocks/sns.api.mock";
import { blockAllCallsTo } from "$tests/utils/module.test-utils";
import type { HttpAgent } from "@dfinity/agent";
import { SnsSwapLifecycle } from "@dfinity/sns";
import { get } from "svelte/store";
import { mock } from "vitest-mock-extended";

Expand Down Expand Up @@ -169,19 +173,19 @@ describe("SNS public services", () => {
it("should build and store wrappers, only for non-aborted SNSes", async () => {
const committedSns1 = aggregatorSnsMockWith({
rootCanisterId: principal(0).toText(),
lifecycle: SnsSwapLifecycle.Committed
lifecycle: SnsSwapLifecycle.Committed,
});
const committedSns2 = aggregatorSnsMockWith({
rootCanisterId: principal(1).toText(),
lifecycle: SnsSwapLifecycle.Committed
lifecycle: SnsSwapLifecycle.Committed,
});
const abortedSns1 = aggregatorSnsMockWith({
rootCanisterId: principal(2).toText(),
lifecycle: SnsSwapLifecycle.Aborted
lifecycle: SnsSwapLifecycle.Aborted,
});
const abortedSns2 = aggregatorSnsMockWith({
rootCanisterId: principal(3).toText(),
lifecycle: SnsSwapLifecycle.Aborted
lifecycle: SnsSwapLifecycle.Aborted,
});

vi.spyOn(aggregatorApi, "querySnsProjects").mockResolvedValue([
Expand All @@ -193,10 +197,17 @@ describe("SNS public services", () => {

await loadSnsProjects();

const wrappers = await getWrappers({identity: mockIdentity, certified: true});
const wrappers = await getWrappers({
identity: mockIdentity,
certified: true,
});
expect(wrappers).toHaveLength(2);
expect(wrappers.has(committedSns1.canister_ids.root_canister_id)).toBe(true);
expect(wrappers.has(committedSns2.canister_ids.root_canister_id)).toBe(true);
expect(wrappers.has(committedSns1.canister_ids.root_canister_id)).toBe(
true
);
expect(wrappers.has(committedSns2.canister_ids.root_canister_id)).toBe(
true
);
});
});
});

0 comments on commit fe6ac38

Please sign in to comment.