Skip to content

Adds unit and e2e tests for CopyrightWaiverStep Component #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 4, 2020
Next Next commit
Adds unit tests for CopyrightWaiverStep Component
  • Loading branch information
JackieBinya committed Apr 2, 2020
commit 99ba7a49d9050d8ea1bb5c404de0fd4dd5ea8d51
118 changes: 118 additions & 0 deletions tests/unit/specs/components/CopyrightWaiverStep.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { createLocalVue, mount } from '@vue/test-utils'
import Buefy from 'buefy'
import Vuex from 'vuex'
import CopyrightWaiverStep from '@/components/CopyrightWaiverStep'

const localVue = createLocalVue()

localVue.use(Vuex)
localVue.use(Buefy)

describe('CopyrightWaiver Step: Check conditional rendering of markup', () => {
let wrapper, state

beforeEach(() => {
wrapper = mount(CopyrightWaiverStep, {
localVue,
data() {
return {
agreed: false,
confirmed: false
}
},
mocks: {
$t: key => key,
}
})
})

afterEach(()=> {
wrapper.destroy()
})

it('Component not mounted if status is inactive', () =>{
wrapper.setProps({
selected: undefined,
status : 'inactive',
stepId: 6,
stepName: 'CW',
})

expect(wrapper.find('.step-description').exists()).toBeFalsy
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
})

it('Step Description block mounted if status is previous', () =>{
wrapper.setProps({status : 'previous'})

expect(wrapper.find('.step-description').exists()).toBeTruthy()
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
})

it('Step Actions block mounted if status is current', () =>{
wrapper.setProps({status : 'current'})

expect(wrapper.find('.step-description').exists()).toBeFalsy()
expect(wrapper.find('.step-actions').exists()).toBeTruthy()
expect(wrapper.vm.copyrightWaiverAgreed).toBe(false)
})

it('User clicks copyright waiver checkbox', () => {
wrapper.setProps({status : 'current'})

const checkbox = wrapper.findAll('input[type="checkbox"]').at(0)
checkbox.setChecked();

console.log(wrapper.emitted())

})

})

describe('Test functionality of computed properties', () => {
let wrapper

beforeEach(() => {
wrapper = mount(CopyrightWaiverStep, {
localVue,
propsData:{
selected: undefined,
status : 'current',
stepId: 6,
stepName: 'CW',
},
mocks: {
$t: key => key,
}
})
})

afterEach(()=> {
wrapper.destroy()
})

it('User checks agreed with confirmed checked', () => {
wrapper.setData({
agreed: false,
confirmed: true
})

const checkbox = wrapper.findAll('input[type="checkbox"]').at(0)
checkbox.setChecked();

expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, true])
})

it('User checks confirmed with agreed checked', () => {
wrapper.setData({
agreed: true,
confirmed: false
})

const checkbox = wrapper.findAll('input[type="checkbox"]').at(1)
checkbox.setChecked();

expect(wrapper.emitted().change[0]).toStrictEqual(['CW', 6, true])
})

})