Pass tests

This commit is contained in:
2020-12-21 14:10:33 +01:00
parent 67680804e2
commit 540521f236
2 changed files with 17 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import { mount, createLocalVue } from "@vue/test-utils"; import { mount, createLocalVue } from "@vue/test-utils";
import Vuex from "vuex"; import Vuex from "vuex";
import Film from "./_id"; import Film from "./_id";
import mockFilms from "@/test/fake-films.json";
let $route = { let $route = {
path: "/films", path: "/films",
@@ -20,7 +21,10 @@ describe("Film page", () => {
film: {} film: {}
}; };
actions = { actions = {
getFilm: jest.fn() getFilm: jest.fn(),
getPeople: jest.fn(),
getVehicles: jest.fn(),
getLocations: jest.fn()
}; };
getters = { getters = {
film: jest.fn() film: jest.fn()
@@ -38,7 +42,13 @@ describe("Film page", () => {
}); });
it("should render Film page instance", () => { it("should render Film page instance", () => {
const wrapper = mount(Film, { localVue, store }); const wrapper = mount(Film, {
localVue,
store,
computed: {
film: () => mockFilms[0]
}
});
expect(wrapper.exists()).toBe(true); expect(wrapper.exists()).toBe(true);
}); });
@@ -59,7 +69,10 @@ describe("Film page", () => {
it("should dispatch getFilm action", async () => { it("should dispatch getFilm action", async () => {
let wrapper = mount(Film, { let wrapper = mount(Film, {
localVue, localVue,
store store,
computed: {
film: () => mockFilms[0]
}
}); });
await wrapper.vm.$options.asyncData({ store, params: $route.params }); await wrapper.vm.$options.asyncData({ store, params: $route.params });

View File

@@ -29,7 +29,7 @@ describe("Vuex actions.", () => {
actions.$axios = null; actions.$axios = null;
await expect(actions.getList({ commit })).rejects.toThrow( await expect(actions.getList({ commit })).rejects.toThrow(
"API Error occurred." "API Error occurred: Cannot read property '$get' of null"
); );
}); });
}); });