49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
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, getters, store;
|
|
|
|
beforeEach(() => {
|
|
state = {
|
|
list: []
|
|
};
|
|
actions = {
|
|
getList: jest.fn()
|
|
};
|
|
getters = {
|
|
list: jest.fn()
|
|
};
|
|
store = new Vuex.Store({
|
|
modules: {
|
|
films: {
|
|
namespaced: true,
|
|
state,
|
|
actions,
|
|
getters
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
it("should render Films page instance", () => {
|
|
const wrapper = shallowMount(Films, { store, localVue });
|
|
expect(wrapper.find("img").exists()).toBe(true);
|
|
});
|
|
|
|
it("should dispatch films/getList action", async () => {
|
|
let wrapper = shallowMount(Films, {
|
|
store,
|
|
localVue
|
|
});
|
|
|
|
await wrapper.vm.$options.asyncData({ store });
|
|
expect(actions.getList).toHaveBeenCalled();
|
|
expect(wrapper.findComponent({ name: "Grid" }).exists()).toBe(true);
|
|
});
|
|
});
|