commit | author | age
|
2fa8ab
|
1 |
import { shallow, mount, createLocalVue } from "@vue/test-utils"; |
A |
2 |
import Vuex from "vuex"; |
111f2f
|
3 |
import TodoItem from "@/components/TodoItem.vue"; |
A |
4 |
// import { expect } from 'chai' |
|
5 |
|
9d6970
|
6 |
import * as all from "../setup.js"; |
2fa8ab
|
7 |
|
A |
8 |
const localVue = createLocalVue(); |
|
9 |
|
|
10 |
localVue.use(Vuex); |
111f2f
|
11 |
|
8a2c1e
|
12 |
const todoItem = { |
D |
13 |
title: "Love Front End testing :)", |
|
14 |
completed: true |
|
15 |
}; |
|
16 |
|
111f2f
|
17 |
describe("TodoItem.vue", () => { |
A |
18 |
it("has the expected html structure", () => { |
2fa8ab
|
19 |
const wrapper = shallow(TodoItem, { |
A |
20 |
propsData: { todoItem } |
111f2f
|
21 |
}); |
78a403
|
22 |
// expect(wrapper.element).toMatchSnapshot(); |
111f2f
|
23 |
}); |
2fa8ab
|
24 |
|
8a2c1e
|
25 |
it("Renders title as 'Love Front End testing :)'", () => { |
2fa8ab
|
26 |
const wrapper = shallow(TodoItem, { |
A |
27 |
propsData: { todoItem } |
7a7144
|
28 |
}); |
8a2c1e
|
29 |
expect(wrapper.vm.todoItem.title).toMatch("Love Front End testing :)"); |
7a7144
|
30 |
}); |
2fa8ab
|
31 |
|
7a7144
|
32 |
it("Renders completed as true", () => { |
2fa8ab
|
33 |
const wrapper = shallow(TodoItem, { |
A |
34 |
propsData: { todoItem } |
7a7144
|
35 |
}); |
A |
36 |
expect(wrapper.vm.todoItem.completed).toEqual(true); |
|
37 |
}); |
8a2c1e
|
38 |
}); |
2fa8ab
|
39 |
|
8a2c1e
|
40 |
let importantTodo; |
2fa8ab
|
41 |
let methods; |
A |
42 |
|
8a2c1e
|
43 |
describe("Important Flag button ", () => { |
D |
44 |
beforeEach(() => { |
|
45 |
importantTodo = { |
|
46 |
title: "Love Front End testing :)", |
|
47 |
completed: true, |
|
48 |
important: true |
|
49 |
}; |
2fa8ab
|
50 |
methods = { markImportant: jest.fn() }; |
8a2c1e
|
51 |
}); |
111f2f
|
52 |
|
8a2c1e
|
53 |
it("should render a button with important flag", () => { |
D |
54 |
const wrapper = mount(TodoItem, { |
|
55 |
propsData: { todoItem: importantTodo } |
|
56 |
}); |
991fcf
|
57 |
// TODO - test goes here! |
8a2c1e
|
58 |
}); |
D |
59 |
it("should set the colour to red when true", () => { |
|
60 |
const wrapper = mount(TodoItem, { |
|
61 |
propsData: { todoItem: importantTodo } |
|
62 |
}); |
991fcf
|
63 |
// TODO - test goes here! |
8a2c1e
|
64 |
}); |
D |
65 |
it("should set the colour to not red when false", () => { |
2fa8ab
|
66 |
importantTodo.important = false; |
8a2c1e
|
67 |
const wrapper = mount(TodoItem, { |
D |
68 |
propsData: { todoItem: importantTodo } |
|
69 |
}); |
991fcf
|
70 |
// TODO - test goes here! |
8a2c1e
|
71 |
}); |
2fa8ab
|
72 |
|
A |
73 |
it("call makImportant when clicked", () => { |
|
74 |
const wrapper = mount(TodoItem, { |
|
75 |
methods, |
|
76 |
propsData: { todoItem: importantTodo } |
|
77 |
}); |
991fcf
|
78 |
// TODO - test goes here! |
8a2c1e
|
79 |
}); |
111f2f
|
80 |
}); |