From 21aa7a2bb105a575b606b24488f22c58180d8e2e Mon Sep 17 00:00:00 2001 From: Jack Hamer Date: Fri, 13 Oct 2023 17:51:49 +0300 Subject: [PATCH] fix: add unit tests for useContractABI --- packages/app/tests/composables/useContractABI.spec.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/app/tests/composables/useContractABI.spec.ts b/packages/app/tests/composables/useContractABI.spec.ts index 56bc4981b8..f4e1040e52 100644 --- a/packages/app/tests/composables/useContractABI.spec.ts +++ b/packages/app/tests/composables/useContractABI.spec.ts @@ -1,4 +1,4 @@ -import { ref } from "vue"; +import { computed, ref } from "vue"; import { describe, expect, it, type SpyInstance, vi } from "vitest"; @@ -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();