Skip to content

Commit

Permalink
Adapt fetchItem mock response in useKeyedCache tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Aug 8, 2024
1 parent 5fd339f commit de92eff
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions client/src/composables/keyedCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemData>(fetchItem);

Expand All @@ -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<ItemData>(fetchItem);

Expand All @@ -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<ItemData>(fetchItem, shouldFetch);
Expand All @@ -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<ItemData>(fetchItem);

Expand All @@ -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<ItemData>(fetchItem, shouldFetch);
Expand All @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit de92eff

Please sign in to comment.