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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
import { ACTIONS } from '../../../../src/store'
import { Wrapper, shallowMount, createLocalVue } from '@vue/test-utils'
import SidebarFeedLinkActions from '../../../../src/components/SidebarFeedLinkActions.vue'
import { FEED_UPDATE_MODE, FEED_ORDER } from '../../../../src/dataservices/feed.service'
describe('SidebarFeedLinkActions.vue', () => {
'use strict'
let wrapper: Wrapper<SidebarFeedLinkActions>
const feeds = [{
id: 1, title: 'first',
}, {
id: 2, title: 'second', folderId: 123,
}]
beforeAll(() => {
const localVue = createLocalVue()
wrapper = shallowMount(SidebarFeedLinkActions, {
localVue,
propsData: {
feedId: 1,
},
mocks: {
$store: {
state: {
feeds,
folders: [],
},
getters: {
feeds,
},
dispatch: jest.fn(),
},
},
})
})
beforeEach(() => {
(wrapper.vm as any).$store.dispatch.mockReset()
})
describe('User Actions', () => {
it('should dispatch message to store with feed object', () => {
(wrapper.vm as any).markRead()
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_MARK_READ, { feed: feeds[0] })
})
it('should dispatch message to store with feed object and pinned', () => {
(wrapper.vm as any).setPinned(true)
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_SET_PINNED, { feed: feeds[0], pinned: true })
})
it('should dispatch message to store with feed object and fullTextEnabled', () => {
(wrapper.vm as any).setOrdering(FEED_ORDER.NEWEST)
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_SET_ORDERING, { feed: feeds[0], ordering: FEED_ORDER.NEWEST })
})
it('should dispatch message to store with feed object and fullTextEnabled', () => {
(wrapper.vm as any).setFullText(true)
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_SET_FULL_TEXT, { feed: feeds[0], fullTextEnabled: true })
})
it('should dispatch message to store with feed object and new updateMode', () => {
(wrapper.vm as any).setUpdateMode(FEED_UPDATE_MODE.IGNORE)
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_SET_UPDATE_MODE, { feed: feeds[0], updateMode: FEED_UPDATE_MODE.IGNORE })
})
it('should dispatch message to store with feed object on rename feed', () => {
window.prompt = jest.fn().mockReturnValue('test');
(wrapper.vm as any).rename()
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_SET_TITLE, { feed: feeds[0], title: 'test' })
})
it('should dispatch message to store with feed object on delete feed', () => {
window.confirm = jest.fn().mockReturnValue(true);
(wrapper.vm as any).deleteFeed()
expect((wrapper.vm as any).$store.dispatch).toHaveBeenCalledWith(ACTIONS.FEED_DELETE, { feed: feeds[0] })
})
})
afterEach(() => {
jest.clearAllMocks()
})
})
|