Skip to content

Commit b547e4d

Browse files
authored
Merge pull request #155 from JackieBinya/ft-dropdown-unit
Adds unit and e2e tests for DropdownStep Component
2 parents ff31a45 + a2ad6f1 commit b547e4d

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

tests/e2e/specs/DropdownStep.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
'@tags': ['ds'],
3+
'DropdownStep'(browser) {
4+
browser
5+
.init()
6+
.assert.elementPresent('.control-label > span')
7+
.click('.control-label > span')
8+
.assert.not.cssClassPresent('.pagination-next', 'disabled')
9+
.click('.pagination-next')
10+
.assert.elementPresent('.select > select')
11+
.click('.select > select')
12+
.click('option[value="CC0 1.0"]')
13+
.assert.not.cssClassPresent('.pagination-next', 'disabled')
14+
.click('.pagination-next')
15+
.assert.visible('.step-description')
16+
.assert.containsText('div.step-description', 'CC0 1.0 Universal')
17+
.end()
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { createLocalVue, mount } from '@vue/test-utils'
2+
import Buefy from 'buefy'
3+
import Vuex from 'vuex'
4+
import DropdownStep from '@/components/DropdownStep'
5+
6+
const localVue = createLocalVue()
7+
8+
localVue.use(Vuex)
9+
localVue.use(Buefy)
10+
11+
describe('DropdownStep', () => {
12+
let wrapper, store, getters, mutations
13+
14+
beforeEach(() => {
15+
getters = {
16+
fullName: jest.fn().mockReturnValue(undefined),
17+
shortName: jest.fn().mockReturnValue(undefined)
18+
}
19+
20+
mutations = {
21+
updateAttributesFromShort: jest.fn()
22+
}
23+
24+
store = new Vuex.Store({
25+
getters,
26+
mutations
27+
})
28+
29+
wrapper = mount(DropdownStep, {
30+
localVue,
31+
propsData: {
32+
stepId: 5,
33+
status: 'current'
34+
},
35+
mocks: {
36+
$t: key => key
37+
},
38+
store
39+
})
40+
})
41+
42+
afterEach(() => {
43+
wrapper.destroy()
44+
})
45+
46+
it('Checks conditional rendering of markup: status is current', () => {
47+
expect(wrapper.find('.step-actions').exists()).toBeTruthy()
48+
})
49+
50+
it('Checks methods: updateSelected', () => {
51+
const options = wrapper.find('select').findAll('option')
52+
53+
options.at(1).setSelected()
54+
55+
expect(wrapper.emitted().input[0]).toStrictEqual(['DD', 5, true])
56+
})
57+
})
58+
59+
describe('DropdownStep', () => {
60+
let wrapper, store, getters
61+
62+
beforeEach(() => {
63+
getters = {
64+
fullName: jest.fn().mockReturnValue('CC 1.0 Universal')
65+
}
66+
67+
store = new Vuex.Store({
68+
getters
69+
})
70+
71+
wrapper = mount(DropdownStep, {
72+
localVue,
73+
mocks: {
74+
$t: key => key
75+
},
76+
store
77+
})
78+
})
79+
80+
afterEach(() => {
81+
wrapper.destroy()
82+
})
83+
84+
it('Checks conditional rendering of markup: status is inactive', () => {
85+
wrapper.setProps({
86+
stepId: 5,
87+
status: 'inactive'
88+
})
89+
expect(wrapper.find('.step-description').exists()).toBeFalsy()
90+
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
91+
})
92+
93+
it('Checks getters and computed property cardText && Checks conditional rendering of markup', () => {
94+
wrapper.setProps({
95+
stepId: 5,
96+
status: 'previous'
97+
})
98+
99+
expect(wrapper.find('.step-description').exists()).toBeTruthy()
100+
expect(wrapper.vm.fullName).toBe('CC 1.0 Universal')
101+
expect(wrapper.vm.cardText).toBe('CC 1.0 Universal')
102+
expect(wrapper.find('.step-description').text()).toBe('CC 1.0 Universal')
103+
})
104+
})

0 commit comments

Comments
 (0)