diff --git a/pages/locations/_id.spec.js b/pages/locations/_id.spec.js index c6a3473..761180b 100644 --- a/pages/locations/_id.spec.js +++ b/pages/locations/_id.spec.js @@ -1,6 +1,7 @@ import { mount, createLocalVue } from "@vue/test-utils"; import Vuex from "vuex"; import Location from "./_id"; +import mockLocations from "@/test/fake-locations.json"; let $route = { path: "/locations", @@ -22,11 +23,25 @@ describe("Location page", () => { actions = { getLocation: jest.fn() }; - store = new Vuex.Store({ state, actions }); + store = new Vuex.Store({ + modules: { + locations: { + namespaced: true, + state, + actions + } + } + }); }); it("should render Location page instance", () => { - const wrapper = mount(Location, { localVue, store }); + const wrapper = mount(Location, { + localVue, + store, + computed: { + location: () => mockLocations[0] + } + }); expect(wrapper.exists()).toBe(true); }); @@ -47,7 +62,10 @@ describe("Location page", () => { it("should dispatch getLocation action", async () => { let wrapper = mount(Location, { localVue, - store + store, + computed: { + location: () => mockLocations[0] + } }); await wrapper.vm.$options.asyncData({ store, params: $route.params }); diff --git a/pages/locations/_id.vue b/pages/locations/_id.vue index d0245b4..2a953e1 100644 --- a/pages/locations/_id.vue +++ b/pages/locations/_id.vue @@ -5,7 +5,7 @@