37 lines
880 B
JavaScript
37 lines
880 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 dispatch getFilms action", 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);
|
|
});
|
|
});
|