From de92eff7057bbd2abfbb590ccb9446f6f1c6e484 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:23:01 +0200 Subject: [PATCH] Adapt fetchItem mock response in useKeyedCache tests --- client/src/composables/keyedCache.test.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/client/src/composables/keyedCache.test.ts b/client/src/composables/keyedCache.test.ts index d792e7d0fd97..3617e66cbc69 100644 --- a/client/src/composables/keyedCache.test.ts +++ b/client/src/composables/keyedCache.test.ts @@ -21,9 +21,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); const { storedItems, getItemById, isLoadingItem } = useKeyedCache(fetchItem); @@ -43,7 +42,7 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; - fetchItem.mockResolvedValue({ data: item }); + fetchItem.mockResolvedValue(item); const { storedItems, getItemById, isLoadingItem } = useKeyedCache(fetchItem); @@ -62,9 +61,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); shouldFetch.mockReturnValue(() => true); const { storedItems, getItemById, isLoadingItem } = useKeyedCache(fetchItem, shouldFetch); @@ -87,9 +85,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); const { storedItems, getItemById, isLoadingItem } = useKeyedCache(fetchItem); @@ -110,9 +107,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); shouldFetch.mockReturnValue(() => true); const { storedItems, getItemById, isLoadingItem } = useKeyedCache(fetchItem, shouldFetch); @@ -135,9 +131,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); const fetchItemRef = ref(fetchItem); @@ -158,9 +153,8 @@ describe("useKeyedCache", () => { const id = "1"; const item = { id: id, name: "Item 1" }; const fetchParams = { id: id }; - const apiResponse = { data: item }; - fetchItem.mockResolvedValue(apiResponse); + fetchItem.mockResolvedValue(item); shouldFetch.mockReturnValue(true); const shouldFetchComputed = computed(() => shouldFetch);