-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathDropdownStep.spec.js
104 lines (84 loc) · 2.58 KB
/
DropdownStep.spec.js
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
96
97
98
99
100
101
102
103
104
import { createLocalVue, mount } from '@vue/test-utils'
import Buefy from 'buefy'
import Vuex from 'vuex'
import DropdownStep from '@/components/DropdownStep'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Buefy)
describe('DropdownStep', () => {
let wrapper, store, getters, mutations
beforeEach(() => {
getters = {
fullName: jest.fn().mockReturnValue(undefined),
shortName: jest.fn().mockReturnValue(undefined)
}
mutations = {
updateAttributesFromShort: jest.fn()
}
store = new Vuex.Store({
getters,
mutations
})
wrapper = mount(DropdownStep, {
localVue,
propsData: {
stepId: 5,
status: 'current'
},
mocks: {
$t: key => key
},
store
})
})
afterEach(() => {
wrapper.destroy()
})
it('Checks conditional rendering of markup: status is current', () => {
expect(wrapper.find('.step-actions').exists()).toBeTruthy()
})
it('Checks methods: updateSelected', () => {
const options = wrapper.find('select').findAll('option')
options.at(1).setSelected()
expect(wrapper.emitted().change[0]).toStrictEqual(['DD', 5, true])
})
})
describe('DropdownStep', () => {
let wrapper, store, getters
beforeEach(() => {
getters = {
fullName: jest.fn().mockReturnValue('CC 1.0 Universal')
}
store = new Vuex.Store({
getters
})
wrapper = mount(DropdownStep, {
localVue,
mocks: {
$t: key => key
},
store
})
})
afterEach(() => {
wrapper.destroy()
})
it('Checks conditional rendering of markup: status is inactive', () => {
wrapper.setProps({
stepId: 5,
status: 'inactive'
})
expect(wrapper.find('.step-description').exists()).toBeFalsy()
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
})
it('Checks getters and computed property cardText && Checks conditional rendering of markup', () => {
wrapper.setProps({
stepId: 5,
status: 'previous'
})
expect(wrapper.find('.step-description').exists()).toBeTruthy()
expect(wrapper.vm.fullName).toBe('CC 1.0 Universal')
expect(wrapper.vm.cardText).toBe('CC 1.0 Universal')
expect(wrapper.find('.step-description').text()).toBe('CC 1.0 Universal')
})
})