Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/e2e/specs/DropdownStep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'@tags': ['ds'],
'DropdownStep'(browser) {
browser
.init()
.assert.elementPresent('.control-label > span')
.click('.control-label > span')
.assert.not.cssClassPresent('.pagination-next', 'disabled')
.click('.pagination-next')
.assert.elementPresent('.select > select')
.click('.select > select')
.click('option[value="CC0 1.0"]')
.assert.not.cssClassPresent('.pagination-next', 'disabled')
.click('.pagination-next')
.assert.visible('.step-description')
.assert.containsText('div.step-description', 'CC0 1.0 Universal')
.end()
}
}
104 changes: 104 additions & 0 deletions tests/unit/specs/components/DropdownStep.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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().input[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')
})
})