donal
2018-04-16 991fcf9223a17ed77d31d5f87b13d759b533aed5
commit | author | age
b0b888 1 import { shallow, createLocalVue, mount } from "@vue/test-utils";
A 2 import Vuex from "vuex";
3 import XofYItems from "@/components/XofYItems.vue";
4
9d6970 5 import * as all from "../setup.js";
b0b888 6
A 7 const localVue = createLocalVue();
8
9 localVue.use(Vuex);
10
11 describe("XofYItems.vue", () => {
12   let store;
13
14   const todos = [
15     {
16       title: "Learn awesome things about Labs",
17       completed: false,
18       important: false
19     }
20   ];
21 //   const methods = {
22 //     sumDoneTodoItems: jest.fn()
23 //   };
24   const actions = {
25     loadTodos: jest.fn(),
26     clearTodos: jest.fn()
27   };
28   const getters = {
29     todos: jest.fn()
30   };
31
32   beforeEach(() => {
33     store = new Vuex.Store({
34       state: {},
35       actions,
36       getters
37     });
38   });
39
40   it("returns the correct length of todos", () => {
41     const mockedTodos = [
42       {
43         title: "Learn awesome things about Labs",
44         completed: true,
45         important: false
46       },
47       {
48         title: "Learn more awesome things about Labs",
49         completed: true,
50         important: false
51       },
52       {
53         title: "Learn even more awesome things about Labs",
54         completed: false,
55         important: false
56       }
57     ];
58
59     expect(mockedTodos.length).toEqual(3)
60     // Replace with testing the sumDoneTodoItems function and check it it's called
61     // expect(sumDoneTodoItems).toHaveBeenCalled()
62   });
63 });