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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
import { ACTIONS } from '../../../../src/store'
import { Wrapper, shallowMount, createLocalVue } from '@vue/test-utils'
import AppSidebar from '../../../../src/components/Sidebar.vue'
describe('Sidebar.vue', () => {
'use strict'
let wrapper: Wrapper<AppSidebar>
beforeAll(() => {
const localVue = createLocalVue()
wrapper = shallowMount(AppSidebar, {
localVue,
mocks: {
$store: {
state: {
feeds: [],
folders: [],
},
dispatch: jest.fn(),
},
},
})
// wrapper.vm.$store.
})
it('should initialize without showing AddFeed Component', () => {
expect((wrapper.vm as any).$data.showAddFeed).toBeFalsy()
})
it('should dispatch message to store with folder name to create new folder', () => {
(wrapper.vm as any).newFolder('abc')
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.ADD_FOLDERS, { folder: { name: 'abc' } })
})
it('should dispatch message to store with folder object on delete folder', () => {
const folder = {};
(wrapper.vm as any).deleteFolder(folder)
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.DELETE_FOLDER, { folder })
})
it('should set showAddFeed to true', () => {
(wrapper.vm as any).showShowAddFeed()
expect(wrapper.vm.$data.showAddFeed).toBeTruthy()
})
it('should set showAddFeed to false', () => {
(wrapper.vm as any).closeShowAddFeed()
expect(wrapper.vm.$data.showAddFeed).toBeFalsy()
})
// TODO: A couple more tests here
it('should return top level nav (folders and feeds without folders)', () => {
const topLevelNav = (wrapper.vm.$options.computed?.topLevelNav as any).call({
$store: {
getters: {
feeds: [],
folders: [],
},
},
})
expect(topLevelNav).toEqual([])
})
// TODO: More Template Testing with https://test-utils.vuejs.org/guide/essentials/a-crash-course.html#adding-a-new-todo
afterEach(() => {
jest.clearAllMocks()
})
describe('SideBar State', () => {
// TODO
})
})
|