test(client): home view (WIP)
parent
c97a6430e0
commit
3f757613d9
|
@ -2,8 +2,9 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
import Home from '../../../src/views/Home.vue';
|
import Home from '../../../src/views/Home.vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// import config from '@/config';
|
import config from '@/config';
|
||||||
import IQuestion from '@/models/question';
|
import questions from '@/store/modules/questions';
|
||||||
|
import schools from '@/store/modules/questions';
|
||||||
|
|
||||||
const localVue = createLocalVue();
|
const localVue = createLocalVue();
|
||||||
|
|
||||||
|
@ -11,49 +12,25 @@ localVue.use(Vuex);
|
||||||
|
|
||||||
const $store = new Vuex.Store({
|
const $store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
questions: {
|
questions,
|
||||||
namespaced: false,
|
schools,
|
||||||
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;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
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', () => {
|
describe.skip('Views - Home', () => {
|
||||||
it('should remove done todos', () => {
|
it('should ', () => {
|
||||||
const storeDispatchMock = spyOn($store, 'dispatch');
|
const storeDispatchMock = spyOn($store, 'dispatch');
|
||||||
const axiosMock = jest
|
|
||||||
.spyOn(axios, 'get')
|
|
||||||
.mockResolvedValue({ data: { questions: [] } } as any);
|
|
||||||
|
|
||||||
// wrapper.find('.todoList__removeDone').trigger('click');
|
// wrapper.find('.todoList__removeDone').trigger('click');
|
||||||
expect(storeDispatchMock).toBeCalledTimes(2);
|
// expect(storeDispatchMock).toBeCalledTimes(2);
|
||||||
expect(storeDispatchMock).toHaveBeenNthCalledWith(1, 'fetchQuestions');
|
// expect(storeDispatchMock).toHaveBeenNthCalledWith(1, 'fetchQuestions');
|
||||||
expect(storeDispatchMock).toHaveBeenNthCalledWith(2, 'fetchSchools');
|
// expect(storeDispatchMock).toHaveBeenNthCalledWith(2, 'fetchSchools');
|
||||||
// expect(axiosMock).toBeCalledTimes(1);
|
expect(axiosMock).toBeCalledTimes(2);
|
||||||
// expect(axiosMock).toHaveBeenCalledWith(`${config.apiUrl}/questions`);
|
expect(axiosMock).toHaveBeenNthCalledWith(1, `${config.apiUrl}/questions`);
|
||||||
|
expect(axiosMock).toHaveBeenNthCalledWith(2, `${config.apiUrl}/schools`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue