Unverified Commit b1509ba7 authored by mvdbeek's avatar mvdbeek
Browse files

Fix client unit tests

parent 4d71d880
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
import "jest-location-mock";

import { getFakeRegisteredUser } from "@tests/test-data";
import { mount } from "@vue/test-utils";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
@@ -8,6 +9,7 @@ import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { ref } from "vue";

import { useServerMock } from "@/api/client/__mocks__";
import toolsList from "@/components/ToolsView/testData/toolsList.json";
import toolsListInPanel from "@/components/ToolsView/testData/toolsListInPanel.json";
import { useUserLocalStorage } from "@/composables/userLocalStorage";
@@ -28,6 +30,7 @@ interface ToolPanelView {
}

const localVue = getLocalVue();
const { server, http } = useServerMock();

const TEST_PANELS_URI = "/api/tool_panels";
const DEFAULT_VIEW_ID = "default";
@@ -90,6 +93,12 @@ describe("ToolPanel", () => {
            axiosMock.onGet(/\/api\/tool_panels\/.*/).reply(200, toolsListInPanel);
        }

        server.use(
            http.get("/api/users/{user_id}", ({ response }) => {
                return response(200).json(getFakeRegisteredUser());
            })
        );

        // setting this because for the default view, we just show "Tools" as the name
        // even though the backend returns "Full Tool Panel"
        viewsList[DEFAULT_VIEW_ID]!.name = "Tools";