test(client): home view
parent
9f311f6f89
commit
4d23f1d91b
|
@ -1,9 +1,9 @@
|
||||||
import { createLocalVue, shallowMount } from "@vue/test-utils";
|
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 IQuestion from '@/models/question';
|
||||||
|
|
||||||
const localVue = createLocalVue();
|
const localVue = createLocalVue();
|
||||||
|
|
||||||
|
@ -16,39 +16,43 @@ const $store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
index: 0,
|
index: 0,
|
||||||
score: 0,
|
score: 0,
|
||||||
question: []
|
question: [],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
index: () => 0,
|
index: () => 0,
|
||||||
score: () => 0,
|
score: () => 0,
|
||||||
schools: () => [],
|
schools: () => [],
|
||||||
currentQuestion: (): IQuestion => {
|
currentQuestion: (): IQuestion => {
|
||||||
return { text: "test", answer: 1 };
|
return { text: 'test', answer: 1 };
|
||||||
},
|
},
|
||||||
questions: (): IQuestion[] => {
|
questions: (): IQuestion[] => {
|
||||||
return [];
|
return [];
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
fetchQuestions: () => {},
|
fetchQuestions: () => {
|
||||||
fetchSchools: () => {}
|
return;
|
||||||
}
|
},
|
||||||
}
|
fetchSchools: () => {
|
||||||
}
|
return;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
shallowMount(Home, { mocks: { $store } });
|
shallowMount(Home, { mocks: { $store } });
|
||||||
|
|
||||||
describe("Views - Home", () => {
|
describe('Views - Home', () => {
|
||||||
it("should remove done todos", () => {
|
it('should remove done todos', () => {
|
||||||
const storeDispatchMock = spyOn($store, "dispatch");
|
const storeDispatchMock = spyOn($store, 'dispatch');
|
||||||
const axiosMock = jest
|
const axiosMock = jest
|
||||||
.spyOn(axios, "get")
|
.spyOn(axios, 'get')
|
||||||
.mockResolvedValue({ data: { questions: [] } } as any);
|
.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(1);
|
||||||
// expect(axiosMock).toHaveBeenCalledWith(`${config.apiUrl}/questions`);
|
// expect(axiosMock).toHaveBeenCalledWith(`${config.apiUrl}/questions`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue