test(client): home view unit test

pull/12/head
sundowndev 2019-12-07 16:56:50 +01:00
parent e402799222
commit 9e6d1142d2
2 changed files with 13 additions and 22 deletions

View File

@ -5,21 +5,16 @@
</template>
<script lang="ts">
import Vue from 'vue';
import { mapState, mapGetters, mapMutations } from 'vuex';
import Quiz from '../components/Quiz.vue';
import Vue from "vue";
import { mapState, mapGetters, mapMutations } from "vuex";
import Quiz from "../components/Quiz.vue";
export default Vue.extend({
name: 'home',
data() {
return {};
},
computed: {},
methods: {},
name: "home",
components: { Quiz },
async created() {
await this.$store.dispatch('questions/fetchQuestions');
await this.$store.dispatch('schools/fetchSchools');
},
await this.$store.dispatch("questions/fetchQuestions");
await this.$store.dispatch("schools/fetchSchools");
}
});
</script>

View File

@ -4,7 +4,7 @@ import Home from '../../../src/views/Home.vue';
import axios from 'axios';
import config from '@/config';
import questions from '@/store/modules/questions';
import schools from '@/store/modules/questions';
import schools from '@/store/modules/schools';
const localVue = createLocalVue();
@ -18,17 +18,13 @@ const $store = new Vuex.Store({
});
const axiosMock = jest
.spyOn(axios, 'get')
.mockResolvedValue({ data: { questions: [] } } as any);
const wrapper = shallowMount(Home, { mocks: { $store } });
.mockResolvedValueOnce({ data: { questions: [] } } as any)
.mockResolvedValueOnce({ data: { schools: [] } } as any);
describe.skip('Views - Home', () => {
it('should ', () => {
const storeDispatchMock = spyOn($store, 'dispatch');
shallowMount(Home, { mocks: { $store } });
// wrapper.find('.todoList__removeDone').trigger('click');
// expect(storeDispatchMock).toBeCalledTimes(2);
// expect(storeDispatchMock).toHaveBeenNthCalledWith(1, 'fetchQuestions');
// expect(storeDispatchMock).toHaveBeenNthCalledWith(2, 'fetchSchools');
describe('Views - Home', () => {
it('should fetch questions and shools', () => {
expect(axiosMock).toBeCalledTimes(2);
expect(axiosMock).toHaveBeenNthCalledWith(1, `${config.apiUrl}/questions`);
expect(axiosMock).toHaveBeenNthCalledWith(2, `${config.apiUrl}/schools`);