Files
ghibli-api/pages/films/index.spec.js
2020-12-18 05:44:23 +01:00

37 lines
881 B
JavaScript

import { mount, shallowMount, createLocalVue } from "@vue/test-utils";
import Vuex from "vuex";
import Films from "./";
const localVue = createLocalVue();
localVue.use(Vuex);
describe("Films page", () => {
let state, actions, store;
beforeEach(() => {
state = {
films: []
};
actions = {
getFilms: jest.fn()
};
store = new Vuex.Store({ state, actions });
});
it("should render Films page instance", () => {
const wrapper = mount(Films, { store, localVue });
expect(wrapper.find("img").exists()).toBe(true);
});
it("should get films from Ghibli API", async () => {
let wrapper = shallowMount(Films, {
store,
localVue
});
await wrapper.vm.$options.asyncData({ store });
expect(actions.getFilms).toHaveBeenCalled();
expect(wrapper.findComponent({ name: "Grid" }).exists()).toBe(true);
});
});