test(client): home view (WIP)

pull/10/head
sundowndev 2019-10-30 13:03:03 +01:00
parent 3b0e14af50
commit b2bac52629
1 changed files with 16 additions and 39 deletions

View File

@ -2,8 +2,9 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vuex from 'vuex';
import Home from '../../../src/views/Home.vue';
import axios from 'axios';
// import config from '@/config';
import IQuestion from '@/models/question';
import config from '@/config';
import questions from '@/store/modules/questions';
import schools from '@/store/modules/questions';
const localVue = createLocalVue();
@ -11,49 +12,25 @@ localVue.use(Vuex);
const $store = new Vuex.Store({
modules: {
questions: {
namespaced: false,
state: {
index: 0,
score: 0,
question: [],
},
getters: {
index: () => 0,
score: () => 0,
schools: () => [],
currentQuestion: (): IQuestion => {
return { text: 'test', answer: 1 };
},
questions: (): IQuestion[] => {
return [];
},
},
actions: {
fetchQuestions: () => {
return;
},
fetchSchools: () => {
return;
},
},
},
questions,
schools,
},
});
shallowMount(Home, { mocks: { $store } });
describe.skip('Views - Home', () => {
it('should remove done todos', () => {
const storeDispatchMock = spyOn($store, 'dispatch');
const axiosMock = jest
.spyOn(axios, 'get')
.mockResolvedValue({ data: { questions: [] } } as any);
const wrapper = shallowMount(Home, { mocks: { $store } });
describe.skip('Views - Home', () => {
it('should ', () => {
const storeDispatchMock = spyOn($store, 'dispatch');
// wrapper.find('.todoList__removeDone').trigger('click');
expect(storeDispatchMock).toBeCalledTimes(2);
expect(storeDispatchMock).toHaveBeenNthCalledWith(1, 'fetchQuestions');
expect(storeDispatchMock).toHaveBeenNthCalledWith(2, 'fetchSchools');
// expect(axiosMock).toBeCalledTimes(1);
// expect(axiosMock).toHaveBeenCalledWith(`${config.apiUrl}/questions`);
// expect(storeDispatchMock).toBeCalledTimes(2);
// expect(storeDispatchMock).toHaveBeenNthCalledWith(1, 'fetchQuestions');
// expect(storeDispatchMock).toHaveBeenNthCalledWith(2, 'fetchSchools');
expect(axiosMock).toBeCalledTimes(2);
expect(axiosMock).toHaveBeenNthCalledWith(1, `${config.apiUrl}/questions`);
expect(axiosMock).toHaveBeenNthCalledWith(2, `${config.apiUrl}/schools`);
});
});