From 3acc67df11409b141e90033a6448501112ae5747 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:05:26 +0200 Subject: [PATCH] Update ToolSelectPreferredObjectStore.test.js With server mock and missing API configuration endpoint. The missing API mock may cause the test to not handle the rejected promise otherwise. --- .../Tool/ToolSelectPreferredObjectStore.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/src/components/Tool/ToolSelectPreferredObjectStore.test.js b/client/src/components/Tool/ToolSelectPreferredObjectStore.test.js index e44f6fb0cfbd..2bbad3ab37ca 100644 --- a/client/src/components/Tool/ToolSelectPreferredObjectStore.test.js +++ b/client/src/components/Tool/ToolSelectPreferredObjectStore.test.js @@ -2,6 +2,7 @@ import { mount } from "@vue/test-utils"; import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; +import { useServerMock } from "@/api/client/__mocks__"; import { setupSelectableMock } from "@/components/ObjectStore/mockServices"; import { ROOT_COMPONENT } from "@/utils/navigation"; @@ -11,7 +12,15 @@ setupSelectableMock(); const localVue = getLocalVue(true); +const { server, http } = useServerMock(); + function mountComponent() { + server.use( + http.get("/api/configuration", ({ response }) => { + return response(200).json({}); + }) + ); + const wrapper = mount(ToolSelectPreferredObjectStore, { propsData: { toolPreferredObjectStoreId: null }, localVue, @@ -24,6 +33,7 @@ const PREFERENCES = ROOT_COMPONENT.preferences; describe("ToolSelectPreferredObjectStore.vue", () => { it("updates object store to default on selection null", async () => { const wrapper = mountComponent(); + await flushPromises(); const els = wrapper.findAll(PREFERENCES.object_store_selection.option_buttons.selector); expect(els.length).toBe(3);