Skip to content

Commit

Permalink
fix: add unit tests for useContractABI
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Oct 13, 2023
1 parent 0d3543a commit 21aa7a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/app/tests/composables/useContractABI.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref } from "vue";
import { computed, ref } from "vue";

import { describe, expect, it, type SpyInstance, vi } from "vitest";

Expand Down Expand Up @@ -66,6 +66,14 @@ describe("useContractABI:", () => {
expect(isRequestFailed.value).toEqual(true);
mock.mockRestore();
});
it("doesn't make request when there is no verification api url", async () => {
const mock = ($fetch as unknown as SpyInstance).mockClear();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { getCollection } = useContractABI({ currentNetwork: computed(() => ({})) } as any);
await getCollection(["0x5550000000000000000000000000000000000000"]);
expect(mock).toHaveBeenCalledTimes(0);
mock.mockRestore();
});
it("caches the results", async () => {
const mock = ($fetch as unknown as SpyInstance).mockClear();
const { getCollection } = useContractABI();
Expand Down

0 comments on commit 21aa7a2

Please sign in to comment.