Fix vehicles details page + pass test

This commit is contained in:
2020-12-21 22:59:09 +01:00
parent 16a0dc47da
commit add48e09a8
2 changed files with 27 additions and 6 deletions

View File

@@ -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 });