Skip to content

Commit

Permalink
Update ToolSelectPreferredObjectStore.test.js
Browse files Browse the repository at this point in the history
With server mock and missing API configuration endpoint. The missing API mock may cause the test to not handle the rejected promise otherwise.
  • Loading branch information
davelopez committed Aug 12, 2024
1 parent 3ff0bdd commit 3acc67d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/src/components/Tool/ToolSelectPreferredObjectStore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

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

0 comments on commit 3acc67d

Please sign in to comment.