From 96ef5eeb2778cea37e5c1c3ce502b684aca3b05f Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 17 Dec 2020 22:30:43 -0500 Subject: [PATCH] Shrink usage of store in jobdestinationparams test, fixes the hang (trying to load user). Still not great, but now everything passes and there are zero warnings. Also shallowmount. --- .../JobDestinationParams.test.js | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/client/src/components/JobDestinationParams/JobDestinationParams.test.js b/client/src/components/JobDestinationParams/JobDestinationParams.test.js index 8ec6a77d7f1..46f52478c62 100644 --- a/client/src/components/JobDestinationParams/JobDestinationParams.test.js +++ b/client/src/components/JobDestinationParams/JobDestinationParams.test.js @@ -1,34 +1,43 @@ import Vuex from "vuex"; -import { mount, createLocalVue } from "@vue/test-utils"; -import { createStore } from "../../store"; +import { shallowMount, createLocalVue } from "@vue/test-utils"; +import createCache from "vuex-cache"; import JobDestinationParams from "./JobDestinationParams"; import jobDestinationResponse from "./testData/jobDestinationResponse"; const JOB_ID = "foo_job_id"; -describe("JobDestinationParams/JobDestinationParams.vue", () => { - const localVue = createLocalVue(); - localVue.use(Vuex); +const localVue = createLocalVue(); +localVue.use(Vuex); - const responseKeys = Object.keys(jobDestinationResponse); - - let testStore; - let wrapper; - - beforeEach(async () => { - testStore = createStore(); - const propsData = { - jobId: JOB_ID, - }; - wrapper = mount(JobDestinationParams, { - store: testStore, - propsData, - localVue, - computed: { - jobDestinationParams() { +const testStore = new Vuex.Store({ + plugins: [createCache()], + modules: { + jobDestinationParametersStore: { + actions: { + fetchJobDestinationParams: jest.fn(), + }, + getters: { + jobDestinationParams: (state) => (job_id) => { return jobDestinationResponse; }, }, + }, + }, +}); + +describe("JobDestinationParams/JobDestinationParams.vue", () => { + const responseKeys = Object.keys(jobDestinationResponse); + + let wrapper; + + beforeEach(async () => { + const propsData = { + jobId: JOB_ID, + }; + wrapper = shallowMount(JobDestinationParams, { + store: testStore, + propsData, + localVue, }); expect(responseKeys.length > 0).toBeTruthy(); });