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
|
import { ACTIONS } from '@/store';
import { Wrapper, shallowMount, createLocalVue } from '@vue/test-utils'
import AppSidebar from '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: []
}
}
}
})
wrapper.vm.$store.dispatch = jest.fn();
})
it('should initialize without showing AddFeed Component', () => {
expect(wrapper.vm.$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.$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.$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
})
afterEach(() => {
jest.clearAllMocks();
});
describe('SideBar State', () => {
// it('should return top level nav (folders and feeds without folders)', () => {
// const navItems = (wrapper.vm.$options?.computed?.topLevelNav as any)({ feeds: [], folders: [] });
// console.log(navItems)
// })
})
})
|