commit | author | age
|
3bd680
|
1 |
/* eslint-disable */ |
90ac1e
|
2 |
import { shallow, createLocalVue } from "@vue/test-utils"; |
A |
3 |
import Vuex from "vuex"; |
|
4 |
import ListOfTodos from "@/components/ListOfTodos.vue"; |
|
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() |
d3c92c
|
23 |
}; |
90ac1e
|
24 |
const getters = { |
A |
25 |
todos: jest.fn() |
d3c92c
|
26 |
}; |
90ac1e
|
27 |
beforeEach(() => { |
A |
28 |
store = new Vuex.Store({ |
|
29 |
state: {}, |
|
30 |
propsData: { todos }, |
d3c92c
|
31 |
actions, |
D |
32 |
getters |
90ac1e
|
33 |
}); |
A |
34 |
}); |
|
35 |
|
|
36 |
it("calls the loadTodos function from actionsjs when created", () => { |
|
37 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
3bd680
|
38 |
expect(wrapper).toBeTruthy(); |
90ac1e
|
39 |
expect(actions.loadTodos).toHaveBeenCalled(); |
d3c92c
|
40 |
}); |
90ac1e
|
41 |
|
A |
42 |
it("maps getters with todos when computed", () => { |
|
43 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
3bd680
|
44 |
expect(wrapper).toBeTruthy(); |
90ac1e
|
45 |
expect(getters.todos).toHaveBeenCalled(); |
d3c92c
|
46 |
}); |
90ac1e
|
47 |
|
A |
48 |
it("has the expected html structure", () => { |
|
49 |
const wrapper = shallow(ListOfTodos, { store, localVue }); |
|
50 |
expect(wrapper.element).toMatchSnapshot(); |
|
51 |
}); |
|
52 |
}); |