diff --git a/app/static/tests/unit/components/actionRequiredMessage.test.ts b/app/static/tests/unit/components/actionRequiredMessage.test.ts index 500d12d0..09c1f30f 100644 --- a/app/static/tests/unit/components/actionRequiredMessage.test.ts +++ b/app/static/tests/unit/components/actionRequiredMessage.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import ActionRequiredMessage from "../../../src/app/components/ActionRequiredMessage.vue"; +import ActionRequiredMessage from "../../../src/components/ActionRequiredMessage.vue"; describe("ActionRequiredMessage", () => { it("renders message in span if present", () => { diff --git a/app/static/tests/unit/components/confirmModal.test.ts b/app/static/tests/unit/components/confirmModal.test.ts index 6d61bd20..b9873122 100644 --- a/app/static/tests/unit/components/confirmModal.test.ts +++ b/app/static/tests/unit/components/confirmModal.test.ts @@ -1,5 +1,5 @@ import { mount } from "@vue/test-utils"; -import ConfirmModal from "../../../src/app/components/ConfirmModal.vue"; +import ConfirmModal from "../../../src/components/ConfirmModal.vue"; describe("ConfirmModal", () => { const getWrapper = (open = true, title = "Delete something", text = "Really?") => { diff --git a/app/static/tests/unit/components/downloadOutput.test.ts b/app/static/tests/unit/components/downloadOutput.test.ts index 1823420d..8a56233c 100644 --- a/app/static/tests/unit/components/downloadOutput.test.ts +++ b/app/static/tests/unit/components/downloadOutput.test.ts @@ -1,8 +1,8 @@ import Vuex from "vuex"; import { shallowMount } from "@vue/test-utils"; import { mockBasicState, mockRunState } from "../../mocks"; -import { BasicState } from "../../../src/app/store/basic/state"; -import DownloadOutput from "../../../src/app/components/DownloadOutput.vue"; +import { BasicState } from "../../../src/store/basic/state"; +import DownloadOutput from "../../../src/components/DownloadOutput.vue"; /* eslint-disable max-len */ const generatedFilenameRegex = @@ -34,7 +34,7 @@ describe("DownloadOutput", () => { }; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it("renders as expected when not open", () => { diff --git a/app/static/tests/unit/components/dropdown.test.ts b/app/static/tests/unit/components/dropdown.test.ts index d195849e..31ea5a50 100644 --- a/app/static/tests/unit/components/dropdown.test.ts +++ b/app/static/tests/unit/components/dropdown.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import DropDown from "../../../src/app/components/DropDown.vue"; +import DropDown from "../../../src/components/DropDown.vue"; describe("dropdown component", () => { const itemList = "
  • test
  • "; diff --git a/app/static/tests/unit/components/errorInfo.test.ts b/app/static/tests/unit/components/errorInfo.test.ts index d6fbcde3..30d11346 100644 --- a/app/static/tests/unit/components/errorInfo.test.ts +++ b/app/static/tests/unit/components/errorInfo.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import ErrorInfo from "../../../src/app/components/ErrorInfo.vue"; +import ErrorInfo from "../../../src/components/ErrorInfo.vue"; describe("ErrorInfo", () => { it("renders as expected with error", () => { @@ -10,7 +10,7 @@ describe("ErrorInfo", () => { }); it("renders as expected with no error", () => { - const wrapper = shallowMount(ErrorInfo, { props: { error: null } }); + const wrapper = shallowMount(ErrorInfo, { props: { error: undefined } }); expect(wrapper.find("div").text()).toBe(""); }); }); diff --git a/app/static/tests/unit/components/errorsAlert.test.ts b/app/static/tests/unit/components/errorsAlert.test.ts index 1db76aa9..4c55dbc4 100644 --- a/app/static/tests/unit/components/errorsAlert.test.ts +++ b/app/static/tests/unit/components/errorsAlert.test.ts @@ -1,13 +1,13 @@ import Vuex from "vuex"; import { shallowMount } from "@vue/test-utils"; import { mockBasicState } from "../../mocks"; -import { BasicState } from "../../../src/app/store/basic/state"; -import ErrorsAlert from "../../../src/app/components/ErrorsAlert.vue"; -import { WodinError } from "../../../src/app/types/responseTypes"; -import { ErrorsMutation } from "../../../src/app/store/errors/mutations"; +import { BasicState } from "../../../src/store/basic/state"; +import ErrorsAlert from "../../../src/components/ErrorsAlert.vue"; +import { WodinError } from "../../../src/types/responseTypes"; +import { ErrorsMutation } from "../../../src/store/errors/mutations"; describe("ErrorsAlert", () => { - const getWrapper = (errors: WodinError[], dismissErrors = jest.fn()) => { + const getWrapper = (errors: WodinError[], dismissErrors = vi.fn()) => { const store = new Vuex.Store({ state: mockBasicState, modules: { @@ -71,7 +71,7 @@ describe("ErrorsAlert", () => { }); it("dismisses errors on close", async () => { - const mockDismissErrors = jest.fn(); + const mockDismissErrors = vi.fn(); const wrapper = getWrapper([{ error: "TEST_CODE", detail: "Test Error Message" }], mockDismissErrors); const closeButton = wrapper.find("button"); await closeButton.trigger("click"); diff --git a/app/static/tests/unit/components/graphSettings.test.ts b/app/static/tests/unit/components/graphSettings.test.ts index 8fc3ee6f..3920341e 100644 --- a/app/static/tests/unit/components/graphSettings.test.ts +++ b/app/static/tests/unit/components/graphSettings.test.ts @@ -1,16 +1,16 @@ import Vuex from "vuex"; import { shallowMount } from "@vue/test-utils"; -import { BasicState } from "../../../src/app/store/basic/state"; -import GraphSettings from "../../../src/app/components/GraphSettings.vue"; -import { GraphsMutation } from "../../../src/app/store/graphs/mutations"; -import { defaultGraphSettings } from "../../../src/app/store/graphs/state"; +import { BasicState } from "../../../src/store/basic/state"; +import GraphSettings from "../../../src/components/GraphSettings.vue"; +import { GraphsMutation } from "../../../src/store/graphs/mutations"; +import { defaultGraphSettings } from "../../../src/store/graphs/state"; describe("GraphSettings", () => { - const mockSetLogScaleYAxis = jest.fn(); - const mockSetLockYAxis = jest.fn(); + const mockSetLogScaleYAxis = vi.fn(); + const mockSetLockYAxis = vi.fn(); - const mockSetFitLogScaleYAxis = jest.fn(); - const mockSetFitLockYAxis = jest.fn(); + const mockSetFitLogScaleYAxis = vi.fn(); + const mockSetFitLockYAxis = vi.fn(); const getWrapper = ( graphIndex: number | undefined = 1, @@ -44,7 +44,7 @@ describe("GraphSettings", () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it("renders as expected when not fit plot", () => { @@ -91,7 +91,7 @@ describe("GraphSettings", () => { expect(mockSetLogScaleYAxis).not.toHaveBeenCalled(); }); - it("commits change to log scale y axis setting, when not fit plot", async () => { + it("commits change to lock y axis setting, when not fit plot", async () => { const wrapper = getWrapper(1, false); const inputs = wrapper.findAll("input"); expect((inputs[1].element as HTMLInputElement).checked).toBe(false); @@ -101,7 +101,7 @@ describe("GraphSettings", () => { expect(mockSetFitLockYAxis).not.toHaveBeenCalled(); }); - it("commits change to log scale y axis setting, when fit plot", async () => { + it("commits change to lock y axis setting, when fit plot", async () => { const wrapper = getWrapper(undefined, true); const inputs = wrapper.findAll("input"); expect((inputs[1].element as HTMLInputElement).checked).toBe(false); diff --git a/app/static/tests/unit/components/loadingButton.test.ts b/app/static/tests/unit/components/loadingButton.test.ts index b417e7ce..e63d8f38 100644 --- a/app/static/tests/unit/components/loadingButton.test.ts +++ b/app/static/tests/unit/components/loadingButton.test.ts @@ -1,5 +1,5 @@ import { mount } from "@vue/test-utils"; -import LoadingButton from "../../../src/app/components/LoadingButton.vue"; +import LoadingButton from "../../../src/components/LoadingButton.vue"; describe("LoadingButton", () => { const getWrapper = (loading = false, isDisabled = false) => { diff --git a/app/static/tests/unit/components/loadingSpinner.test.ts b/app/static/tests/unit/components/loadingSpinner.test.ts index 5d263560..be0af1b0 100644 --- a/app/static/tests/unit/components/loadingSpinner.test.ts +++ b/app/static/tests/unit/components/loadingSpinner.test.ts @@ -1,5 +1,5 @@ import { mount } from "@vue/test-utils"; -import LoadingSpinner from "../../../src/app/components/LoadingSpinner.vue"; +import LoadingSpinner from "../../../src/components/LoadingSpinner.vue"; describe("LoadingSpinner", () => { it("renders as expected", () => { diff --git a/app/static/tests/unit/components/sessionInitialiseModal.test.ts b/app/static/tests/unit/components/sessionInitialiseModal.test.ts index 574286ad..f944fa3f 100644 --- a/app/static/tests/unit/components/sessionInitialiseModal.test.ts +++ b/app/static/tests/unit/components/sessionInitialiseModal.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import SessionInitialiseModal from "../../../src/app/components/SessionInitialiseModal.vue"; +import SessionInitialiseModal from "../../../src/components/SessionInitialiseModal.vue"; describe("SessionInitialiseModal", () => { const getWrapper = (open = true) => { diff --git a/app/static/tests/unit/components/verticalCollapse.test.ts b/app/static/tests/unit/components/verticalCollapse.test.ts index 868df25c..cb794bef 100644 --- a/app/static/tests/unit/components/verticalCollapse.test.ts +++ b/app/static/tests/unit/components/verticalCollapse.test.ts @@ -1,6 +1,6 @@ import { shallowMount } from "@vue/test-utils"; import VueFeather from "vue-feather"; -import VerticalCollapse from "../../../src/app/components/VerticalCollapse.vue"; +import VerticalCollapse from "../../../src/components/VerticalCollapse.vue"; describe("VerticalCollapse", () => { const getWrapper = (collapsedDefault = false) => { diff --git a/app/static/tests/unit/components/wodinApp.test.ts b/app/static/tests/unit/components/wodinApp.test.ts index 2957af37..aee0359d 100644 --- a/app/static/tests/unit/components/wodinApp.test.ts +++ b/app/static/tests/unit/components/wodinApp.test.ts @@ -1,23 +1,23 @@ import Vuex from "vuex"; import { mount } from "@vue/test-utils"; import { mockBasicState, mockSessionsState } from "../../mocks"; -import { BasicState } from "../../../src/app/store/basic/state"; -import LoadingSpinner from "../../../src/app/components/LoadingSpinner.vue"; -import WodinPanels from "../../../src/app/components/WodinPanels.vue"; -import ErrorsAlert from "../../../src/app/components/ErrorsAlert.vue"; -import WodinApp from "../../../src/app/components/WodinApp.vue"; -import { SessionsState } from "../../../src/app/store/sessions/state"; -import SessionInitialiseModal from "../../../src/app/components/SessionInitialiseModal.vue"; -import { AppStateAction } from "../../../src/app/store/appState/actions"; +import { BasicState } from "../../../src/store/basic/state"; +import LoadingSpinner from "../../../src/components/LoadingSpinner.vue"; +import WodinPanels from "../../../src/components/WodinPanels.vue"; +import ErrorsAlert from "../../../src/components/ErrorsAlert.vue"; +import WodinApp from "../../../src/components/WodinApp.vue"; +import { SessionsState } from "../../../src/store/sessions/state"; +import SessionInitialiseModal from "../../../src/components/SessionInitialiseModal.vue"; +import { AppStateAction } from "../../../src/store/appState/actions"; function mockResizeObserver(this: any) { - this.observe = jest.fn(); - this.disconnect = jest.fn(); + this.observe = vi.fn(); + this.disconnect = vi.fn(); } (global.ResizeObserver as any) = mockResizeObserver; describe("WodinApp", () => { - const mockInitialiseSession = jest.fn(); + const mockInitialiseSession = vi.fn(); const getWrapper = (appState: Partial = {}, sessionsState: Partial = {}) => { const state = mockBasicState(appState); const props = { @@ -58,7 +58,7 @@ describe("WodinApp", () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); it("renders as expected when config is set", () => { diff --git a/app/static/tests/unit/components/wodinPanels.test.ts b/app/static/tests/unit/components/wodinPanels.test.ts index d7096ddd..88d107da 100644 --- a/app/static/tests/unit/components/wodinPanels.test.ts +++ b/app/static/tests/unit/components/wodinPanels.test.ts @@ -1,9 +1,9 @@ import { nextTick } from "vue"; import { shallowMount, VueWrapper } from "@vue/test-utils"; -import WodinPanels from "../../../src/app/components/WodinPanels.vue"; +import WodinPanels from "../../../src/components/WodinPanels.vue"; -const docAddListenerSpy = jest.spyOn(document, "addEventListener"); -const docRemoveListenerSpy = jest.spyOn(document, "removeEventListener"); +const docAddListenerSpy = vi.spyOn(document, "addEventListener"); +const docRemoveListenerSpy = vi.spyOn(document, "removeEventListener"); enum PanelsMode { Left, @@ -28,8 +28,8 @@ enum DragStart { Edge } -const mockObserve = jest.fn(); -const mockDisconnect = jest.fn(); +const mockObserve = vi.fn(); +const mockDisconnect = vi.fn(); function mockResizeObserver(this: any) { this.observe = mockObserve; this.disconnect = mockDisconnect; @@ -45,7 +45,7 @@ const windowBoundaryRight = windowWidth - widthToleranceRight; const snapToleranceLeft = windowBoundaryLeft / 3; const snapToleranceRight = windowWidth - widthToleranceRight / 3; -const mockPreventDefault = jest.fn(); +const mockPreventDefault = vi.fn(); describe("WodinPanels", () => { const getWrapper = () => { @@ -163,7 +163,7 @@ describe("WodinPanels", () => { }; beforeEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it("has expected slot content", () => { diff --git a/app/static/tests/unit/components/wodinPlot.test.ts b/app/static/tests/unit/components/wodinPlot.test.ts index 4227f6a0..9972fd14 100644 --- a/app/static/tests/unit/components/wodinPlot.test.ts +++ b/app/static/tests/unit/components/wodinPlot.test.ts @@ -1,29 +1,33 @@ // Mock the import of plotly so we can mock Plotly methods -jest.mock("plotly.js-basic-dist-min", () => ({ - newPlot: jest.fn(), - react: jest.fn(), +const { + mockPlotlyNewPlot, + mockPlotlyReact, + mockPlotlyResize +} = vi.hoisted(() => ({ + mockPlotlyNewPlot: vi.fn(), + mockPlotlyReact: vi.fn(), + mockPlotlyResize: vi.fn() +})); +vi.mock("plotly.js-basic-dist-min", () => ({ + newPlot: mockPlotlyNewPlot, + react: mockPlotlyReact, Plots: { - resize: jest.fn() + resize: mockPlotlyResize } })); -/* eslint-disable import/first */ import { shallowMount, VueWrapper } from "@vue/test-utils"; import { nextTick } from "vue"; import Vuex, { Store } from "vuex"; -import * as plotly from "plotly.js-basic-dist-min"; -import WodinPlot from "../../../src/app/components/WodinPlot.vue"; -import WodinPlotDataSummary from "../../../src/app/components/WodinPlotDataSummary.vue"; -import { BasicState } from "../../../src/app/store/basic/state"; -import { GraphsMutation } from "../../../src/app/store/graphs/mutations"; -import { defaultGraphSettings } from "../../../src/app/store/graphs/state"; +import WodinPlot from "../../../src/components/WodinPlot.vue"; +import WodinPlotDataSummary from "../../../src/components/WodinPlotDataSummary.vue"; +import { BasicState } from "../../../src/store/basic/state"; +import { GraphsMutation } from "../../../src/store/graphs/mutations"; +import { defaultGraphSettings } from "@/store/graphs/state"; describe("WodinPlot", () => { - const mockPlotlyNewPlot = jest.spyOn(plotly, "newPlot"); - const mockPlotlyReact = jest.spyOn(plotly, "react"); - - const mockObserve = jest.fn(); - const mockDisconnect = jest.fn(); + const mockObserve = vi.fn(); + const mockDisconnect = vi.fn(); function mockResizeObserver(this: any) { this.observe = mockObserve; this.disconnect = mockDisconnect; @@ -50,21 +54,20 @@ describe("WodinPlot", () => { } } ]; - const mockPlotDataFn = jest.fn().mockReturnValue(mockPlotData); const settings = defaultGraphSettings(); const defaultProps = { fadePlot: false, endTime: 99, redrawWatches: [], - plotData: mockPlotDataFn, + plotData: () => mockPlotData as any, placeholderMessage: "No data available", fitPlot: false, graphIndex: 1, - graphConfig: { settings } + graphConfig: { settings } as any }; - const mockSetYAxisRange = jest.fn(); - const mockSetFitYAxisRange = jest.fn(); + const mockSetYAxisRange = vi.fn(); + const mockSetFitYAxisRange = vi.fn(); const getStore = (fitGraphSettings = defaultGraphSettings()) => { return new Vuex.Store({ @@ -105,15 +108,16 @@ describe("WodinPlot", () => { const mockPlotElementOn = (wrapper: VueWrapper) => { const divElement = wrapper.find("div.plot").element; - const mockOn = jest.fn(); + const mockOn = vi.fn(); (divElement as any).on = mockOn; (divElement as any).layout = mockLayout; return mockOn; }; afterEach(() => { - jest.clearAllMocks(); - jest.restoreAllMocks(); + vi.clearAllMocks(); + vi.restoreAllMocks(); + mockSetYAxisRange.mockReset(); }); it("renders plot ref element", () => { @@ -152,7 +156,6 @@ describe("WodinPlot", () => { it("renders data summary", async () => { const wrapper = getWrapper(); mockPlotElementOn(wrapper); - await wrapper.setProps({ redrawWatches: [{} as any] }); const summary = wrapper.findComponent(WodinPlotDataSummary); expect(summary.exists()).toBe(true); @@ -161,10 +164,11 @@ describe("WodinPlot", () => { it("draws plot and sets event handler when solutions are updated", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const mockOn = mockPlotElementOn(wrapper); - - wrapper.setProps({ redrawWatches: [{} as any] }); - await nextTick(); + await wrapper.setProps({ redrawWatches: [{} as any] }); + expect(mockPlotDataFn).toHaveBeenCalled() expect(mockPlotDataFn.mock.calls[0][0]).toBe(0); expect(mockPlotDataFn.mock.calls[0][1]).toBe(99); expect(mockPlotDataFn.mock.calls[0][2]).toBe(1000); @@ -184,6 +188,8 @@ describe("WodinPlot", () => { it("does not set up relayout event handler when recalculateOnRelayout is false", async () => { const wrapper = getWrapper({ recalculateOnRelayout: false }); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const mockOn = mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); @@ -196,7 +202,7 @@ describe("WodinPlot", () => { it("does not draw run plot if base data is null", async () => { const wrapper = getWrapper(); - wrapper.setProps({ redrawWatches: [{} as any], plotData: () => null }); + wrapper.setProps({ redrawWatches: [{} as any], plotData: () => null as any }); await nextTick(); expect(mockPlotlyNewPlot).not.toHaveBeenCalled(); @@ -210,6 +216,8 @@ describe("WodinPlot", () => { it("relayout reruns plotData and calls react if not autorange", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); @@ -238,6 +246,9 @@ describe("WodinPlot", () => { it("relayout uses base data and calls react if autorange", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); + mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); @@ -272,6 +283,8 @@ describe("WodinPlot", () => { }, store ); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const { relayout } = wrapper.vm as any; const relayoutEvent = { "xaxis.autorange": false, @@ -325,6 +338,8 @@ describe("WodinPlot", () => { it("relayout does nothing on autorange false if t0 is undefined", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); @@ -345,6 +360,8 @@ describe("WodinPlot", () => { it("relayout does nothing on autorange false if t1 is undefined", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); @@ -383,7 +400,7 @@ describe("WodinPlot", () => { (wrapper.vm as any).resize(); const divElement = wrapper.find("div.plot").element; - expect(plotly.Plots.resize).toHaveBeenCalledWith(divElement); + expect(mockPlotlyResize).toHaveBeenCalledWith(divElement); }); it("disconnects resizeObserver on unmount", async () => { @@ -498,7 +515,7 @@ describe("WodinPlot", () => { (wrapper.vm as any).plot = { layout: mockLayout, - on: jest.fn() + on: vi.fn() }; await nextTick(); await wrapper.setProps({ redrawWatches: [{} as any] }); @@ -514,7 +531,7 @@ describe("WodinPlot", () => { (wrapper.vm as any).plot = { layout: mockLayout, - on: jest.fn() + on: vi.fn() }; await nextTick(); await wrapper.setProps({ redrawWatches: [{} as any] }); @@ -560,6 +577,8 @@ describe("WodinPlot", () => { it("does not re-draw plot if plot is faded", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const mockOn = mockPlotElementOn(wrapper); await wrapper.setProps({ fadePlot: true }); @@ -572,6 +591,8 @@ describe("WodinPlot", () => { it("re-draws plot if yaxis graph setting toggled", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const mockOn = mockPlotElementOn(wrapper); await wrapper.setProps({ redrawWatches: [{} as any] }); @@ -582,7 +603,7 @@ describe("WodinPlot", () => { await wrapper.setProps({ graphConfig: { settings: { ...defaultGraphSettings(), logScaleYAxis: true } - } + } as any }); await nextTick(); @@ -593,6 +614,8 @@ describe("WodinPlot", () => { it("does not re-draw plot if plot is faded (yaxis toggle)", async () => { const wrapper = getWrapper(); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); const mockOn = mockPlotElementOn(wrapper); await wrapper.setProps({ redrawWatches: [{} as any] }); @@ -604,7 +627,7 @@ describe("WodinPlot", () => { fadePlot: true, graphConfig: { settings: { ...defaultGraphSettings(), logScaleYAxis: true } - } + } as any }); await nextTick(); @@ -641,6 +664,8 @@ describe("WodinPlot", () => { it("update to linkedXAxis triggers relayout", async () => { const wrapper = getWrapper({ linkedXAxis: { autorange: true } }); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); mockPlotElementOn(wrapper); wrapper.setProps({ linkedXAxis: { autorange: false, range: [4, 6] } }); await nextTick(); @@ -658,6 +683,8 @@ describe("WodinPlot", () => { const wrapper = getWrapper({ linkedXAxis: { autorange: false, range: [3, 5] } }); + const mockPlotDataFn = vi.fn().mockReturnValue(mockPlotData); + await wrapper.setProps({ plotData: mockPlotDataFn }); mockPlotElementOn(wrapper); wrapper.setProps({ redrawWatches: [{} as any] }); diff --git a/app/static/tests/unit/components/wodinPlotDataSummary.test.ts b/app/static/tests/unit/components/wodinPlotDataSummary.test.ts index e6fa5482..64ed9850 100644 --- a/app/static/tests/unit/components/wodinPlotDataSummary.test.ts +++ b/app/static/tests/unit/components/wodinPlotDataSummary.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import WodinPlotDataSummary from "../../../src/app/components/WodinPlotDataSummary.vue"; +import WodinPlotDataSummary from "../../../src/components/WodinPlotDataSummary.vue"; describe("WodinPlotDataSummary", () => { const getWrapper = () => { diff --git a/app/static/tests/unit/components/wodinSession.test.ts b/app/static/tests/unit/components/wodinSession.test.ts index 561d9aa6..51830835 100644 --- a/app/static/tests/unit/components/wodinSession.test.ts +++ b/app/static/tests/unit/components/wodinSession.test.ts @@ -2,26 +2,27 @@ import { shallowMount, VueWrapper } from "@vue/test-utils"; import { RouterView } from "vue-router"; import Vuex, { Store } from "vuex"; import { nextTick } from "vue"; -import WodinSession from "../../../src/app/components/WodinSession.vue"; -import { AppStateAction } from "../../../src/app/store/appState/actions"; +import WodinSession from "../../../src/components/WodinSession.vue"; +import { AppStateAction } from "../../../src/store/appState/actions"; import { mockBasicState } from "../../mocks"; -import { BasicState } from "../../../src/app/store/basic/state"; -import { ErrorsMutation } from "../../../src/app/store/errors/mutations"; -import { Language } from "../../../src/app/types/languageTypes"; -import { AppConfigBase, SessionMetadata } from "../../../src/app/types/responseTypes"; -import { mutations as sessionsMutations, SessionsMutation } from "../../../src/app/store/sessions/mutations"; -import { getters as appStateGetters } from "../../../src/app/store/appState/getters"; -import { localStorageManager } from "../../../src/app/localStorageManager"; +import { BasicState } from "../../../src/store/basic/state"; +import { ErrorsMutation } from "../../../src/store/errors/mutations"; +import { Language } from "../../../src/types/languageTypes"; +import { AppConfigBase, SessionMetadata } from "../../../src/types/responseTypes"; +import { mutations as sessionsMutations, SessionsMutation } from "../../../src/store/sessions/mutations"; +import { getters as appStateGetters } from "../../../src/store/appState/getters"; +import { localStorageManager } from "../../../src/localStorageManager"; import { LanguageState } from "../../../translationPackage/store/state"; +import { MockInstance } from "vitest"; const realLocation = window.location; describe("WodinSession", () => { - const mockInitialiseApp = jest.fn(); - const mockAddError = jest.fn(); + const mockInitialiseApp = vi.fn(); + const mockAddError = vi.fn(); const mockGetSessionIds = (sessionIds = ["1234", "5678"]) => - jest.spyOn(localStorageManager, "getSessionIds").mockReturnValue(sessionIds); - const mockSetLatestSessionId = jest.fn(); + vi.spyOn(localStorageManager, "getSessionIds").mockReturnValue(sessionIds); + const mockSetLatestSessionId = vi.fn(); const defaultBaseUrl = "http://localhost:3000/site1"; const defaultLanguage = { @@ -31,7 +32,7 @@ describe("WodinSession", () => { }; beforeEach(() => { - jest.clearAllMocks(); + vi.clearAllMocks(); }); interface StoreOptions { @@ -121,7 +122,7 @@ describe("WodinSession", () => { const expectCheckedLatestSessionId = ( wrapper: VueWrapper, - getSessionIds: jest.SpyInstance, + getSessionIds: MockInstance, expectCommitLatestSessionId: boolean ) => { expect(getSessionIds).toHaveBeenCalledWith("test", "site1"); diff --git a/app/static/tests/unit/components/wodinTabs.test.ts b/app/static/tests/unit/components/wodinTabs.test.ts index 05ca9042..ed485284 100644 --- a/app/static/tests/unit/components/wodinTabs.test.ts +++ b/app/static/tests/unit/components/wodinTabs.test.ts @@ -1,5 +1,5 @@ import { shallowMount } from "@vue/test-utils"; -import WodinTabs from "../../../src/app/components/WodinTabs.vue"; +import WodinTabs from "../../../src/components/WodinTabs.vue"; describe("WodinTabs", () => { const getWrapper = () => {