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