From 16a0dc47dae6a35dc132f5e4a4e97a0990178612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 21 Dec 2020 22:56:28 +0100 Subject: [PATCH] Fix locations details page + pass test --- pages/locations/_id.spec.js | 24 +++++++++++++++++++++--- pages/locations/_id.vue | 9 ++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) 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 @@