Create vuex modules for Films/Vehicles/Locations/People + Test adaptation

This commit is contained in:
2020-12-21 12:01:36 +01:00
parent d8cfe69fa0
commit fffbc87964
12 changed files with 172 additions and 95 deletions

View File

@@ -6,31 +6,43 @@ const localVue = createLocalVue();
localVue.use(Vuex);
describe("Films page", () => {
let state, actions, store;
let state, actions, getters, store;
beforeEach(() => {
state = {
films: []
list: []
};
actions = {
getFilms: jest.fn()
getList: jest.fn()
};
store = new Vuex.Store({ state, actions });
getters = {
list: jest.fn()
};
store = new Vuex.Store({
modules: {
films: {
namespaced: true,
state,
actions,
getters
}
}
});
});
it("should render Films page instance", () => {
const wrapper = mount(Films, { store, localVue });
const wrapper = shallowMount(Films, { store, localVue });
expect(wrapper.find("img").exists()).toBe(true);
});
it("should dispatch getFilms action", async () => {
it("should dispatch films/getList action", async () => {
let wrapper = shallowMount(Films, {
store,
localVue
});
await wrapper.vm.$options.asyncData({ store });
expect(actions.getFilms).toHaveBeenCalled();
expect(actions.getList).toHaveBeenCalled();
expect(wrapper.findComponent({ name: "Grid" }).exists()).toBe(true);
});
});