From 540521f2364df7390d5b0fb3495e3f50d9ea0434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 21 Dec 2020 14:10:33 +0100 Subject: [PATCH] Pass tests --- pages/films/_id.spec.js | 19 ++++++++++++++++--- store/films/actions.spec.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/pages/films/_id.spec.js b/pages/films/_id.spec.js index 5c99436..e4fb5a5 100644 --- a/pages/films/_id.spec.js +++ b/pages/films/_id.spec.js @@ -1,6 +1,7 @@ import { mount, createLocalVue } from "@vue/test-utils"; import Vuex from "vuex"; import Film from "./_id"; +import mockFilms from "@/test/fake-films.json"; let $route = { path: "/films", @@ -20,7 +21,10 @@ describe("Film page", () => { film: {} }; actions = { - getFilm: jest.fn() + getFilm: jest.fn(), + getPeople: jest.fn(), + getVehicles: jest.fn(), + getLocations: jest.fn() }; getters = { film: jest.fn() @@ -38,7 +42,13 @@ describe("Film page", () => { }); 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); }); @@ -59,7 +69,10 @@ describe("Film page", () => { it("should dispatch getFilm action", async () => { let wrapper = mount(Film, { localVue, - store + store, + computed: { + film: () => mockFilms[0] + } }); await wrapper.vm.$options.asyncData({ store, params: $route.params }); diff --git a/store/films/actions.spec.js b/store/films/actions.spec.js index be67e11..d0c35b4 100644 --- a/store/films/actions.spec.js +++ b/store/films/actions.spec.js @@ -29,7 +29,7 @@ describe("Vuex actions.", () => { actions.$axios = null; await expect(actions.getList({ commit })).rejects.toThrow( - "API Error occurred." + "API Error occurred: Cannot read property '$get' of null" ); }); });