test(client): home view (WIP)

pull/11/head
sundowndev 2019-10-30 13:03:03 +01:00
parent c97a6430e0
commit 3f757613d9
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 } });
const axiosMock = jest
.spyOn(axios, 'get')
.mockResolvedValue({ data: { questions: [] } } as any);
const wrapper = shallowMount(Home, { mocks: { $store } });
describe.skip('Views - Home', () => {
it('should remove done todos', () => {
it('should ', () => {
const storeDispatchMock = spyOn($store, 'dispatch');
const axiosMock = jest
.spyOn(axios, 'get')
.mockResolvedValue({ data: { questions: [] } } as any);
// 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`);
});
});