From add48e09a8321564922bb083d34fedd6762fb2c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 21 Dec 2020 22:59:09 +0100 Subject: [PATCH] Fix vehicles details page + pass test --- pages/vehicles/_id.spec.js | 24 +++++++++++++++++++++--- pages/vehicles/_id.vue | 9 ++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pages/vehicles/_id.spec.js b/pages/vehicles/_id.spec.js index 0a3088e..c26e049 100644 --- a/pages/vehicles/_id.spec.js +++ b/pages/vehicles/_id.spec.js @@ -1,6 +1,7 @@ import { mount, createLocalVue } from "@vue/test-utils"; import Vuex from "vuex"; import Vehicle from "./_id"; +import mockVehicles from "@/test/fake-vehicles.json"; let $route = { path: "/vehicles", @@ -22,11 +23,25 @@ describe("Vehicle page", () => { actions = { getVehicle: jest.fn() }; - store = new Vuex.Store({ state, actions }); + store = new Vuex.Store({ + modules: { + vehicles: { + namespaced: true, + state, + actions + } + } + }); }); it("should render Vehicle page instance", () => { - const wrapper = mount(Vehicle, { localVue, store }); + const wrapper = mount(Vehicle, { + localVue, + store, + computed: { + vehicle: () => mockVehicles[0] + } + }); expect(wrapper.exists()).toBe(true); }); @@ -47,7 +62,10 @@ describe("Vehicle page", () => { it("should dispatch getVehicle action", async () => { let wrapper = mount(Vehicle, { localVue, - store + store, + computed: { + vehicle: () => mockVehicles[0] + } }); await wrapper.vm.$options.asyncData({ store, params: $route.params }); diff --git a/pages/vehicles/_id.vue b/pages/vehicles/_id.vue index 371312e..43dce7a 100644 --- a/pages/vehicles/_id.vue +++ b/pages/vehicles/_id.vue @@ -5,7 +5,7 @@