commit | author | age
|
90ac1e
|
1 |
import { shallow, createLocalVue } from "@vue/test-utils"; |
A |
2 |
import Vuex from "vuex"; |
|
3 |
import ListOfTodos from "@/components/ListOfTodos.vue"; |
|
4 |
// import { expect } from 'chai' |
|
5 |
|
9d6970
|
6 |
import * as all from "../setup.js"; |
90ac1e
|
7 |
|
A |
8 |
const localVue = createLocalVue(); |
|
9 |
|
|
10 |
localVue.use(Vuex); |
|
11 |
|
|
12 |
describe("ListOfTodos.vue", () => { |
|
13 |
let store; |
|
14 |
const todos = [ |
|
15 |
{ |
|
16 |
title: "Learn awesome things about Labs", |
|
17 |
completed: false, |
|
18 |
important: false |
|
19 |
} |
|
20 |
]; |
|
21 |
const actions = { |
|
22 |
loadTodos: jest.fn() |
|
23 |
} |
|
24 |
const getters = { |
|
25 |
todos: jest.fn() |
|
26 |
} |
|
27 |
beforeEach(() => { |
|
28 |
|
|
29 |
store = new Vuex.Store({ |
|
30 |
state: {}, |
|
31 |
propsData: { todos }, |
|
32 |
actions, getters |
|
33 |
}); |
|
34 |
}); |
|
35 |
|
|
36 |
it("calls the loadTodos function from actionsjs when created", () => { |
|
37 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
|
38 |
expect(actions.loadTodos).toHaveBeenCalled(); |
|
39 |
}) |
|
40 |
|
|
41 |
it("maps getters with todos when computed", () => { |
|
42 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
|
43 |
expect(getters.todos).toHaveBeenCalled(); |
|
44 |
}) |
|
45 |
|
|
46 |
it("has the expected html structure", () => { |
|
47 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
|
48 |
expect(wrapper.element).toMatchSnapshot(); |
|
49 |
}); |
|
50 |
}); |