diff --git a/client/src/components/Upload/UploadModal.test.js b/client/src/components/Upload/UploadModal.test.js index 8c2317b1f88..c0e466c2f01 100644 --- a/client/src/components/Upload/UploadModal.test.js +++ b/client/src/components/Upload/UploadModal.test.js @@ -2,12 +2,12 @@ import MockAdapter from "axios-mock-adapter"; import axios from "axios"; import UploadModal from "./UploadModal"; import UploadModalContent from "./UploadModalContent"; -import store from "../../store"; import { mount } from "@vue/test-utils"; -import { getLocalVue } from "jest/helpers"; - -import MockCurrentUser from "../providers/MockCurrentUser"; -import MockCurrentHistory from "../providers/MockCurrentHistory"; +import { getLocalVue, mockModule } from "jest/helpers"; +import { userStore } from "store/userStore"; +import { historyStore } from "store/historyStore"; +import { configStore } from "store/configStore"; +import Vuex from "vuex"; jest.mock("app"); @@ -17,6 +17,16 @@ const propsData = { fileSourcesConfigured: true, }; +const createStore = () => { + return new Vuex.Store({ + modules: { + user: mockModule(userStore, { currentUser: { id: "fakeuser" } }), + history: mockModule(historyStore, { currentHistoryId: "fakehistory", histories: { fakehistory: {} } }), + config: mockModule(configStore, { config: {} }), + }, + }); +}; + describe("UploadModal.vue", () => { let wrapper; let axiosMock; @@ -47,17 +57,14 @@ describe("UploadModal.vue", () => { axiosMock.onGet(`/api/datatypes?extension_only=False`).reply(200, datatypesResponse); const localVue = getLocalVue(); + const store = createStore(); wrapper = await mount(UploadModal, { store, + provide: { store }, propsData, localVue, stubs: { - // Need to stub all this horrible-ness because of the last 2 tests - // which need to dig into the first layer of the mount tree, will remove - // all of this shortly with a PR that completely replaces Upload - CurrentUser: MockCurrentUser({ id: "fakeuser" }), - UserHistories: MockCurrentHistory({ id: "fakehistory" }), BTabs: true, BTab: true, Collection: true, @@ -66,6 +73,8 @@ describe("UploadModal.vue", () => { RulesInput: true, }, }); + + await wrapper.vm.open(); }); afterEach(() => { @@ -74,8 +83,9 @@ describe("UploadModal.vue", () => { }); it("should load with correct defaults", async () => { - expect(wrapper.vm.auto.id).toBe("auto"); - expect(wrapper.vm.datatypesDisableAuto).toBe(false); + const contentWrapper = wrapper.findComponent(UploadModalContent); + expect(contentWrapper.vm.auto.id).toBe("auto"); + expect(contentWrapper.vm.datatypesDisableAuto).toBe(false); }); it("should fetch datatypes and parse them", async () => {