Create vuex modules for Films/Vehicles/Locations/People + Test adaptation
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user