1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-08 02:58:54 +08:00

add checkBox tests

This commit is contained in:
lana-k
2021-01-01 21:14:57 +01:00
parent ef461be3e5
commit e98fa8793b
4 changed files with 49 additions and 26 deletions

View File

@@ -0,0 +1,39 @@
import { expect } from 'chai'
import { shallowMount } from '@vue/test-utils'
import CheckBox from '@/components/CheckBox'
describe('CheckBox', () => {
it('unchecked by default', () => {
const wrapper = shallowMount(CheckBox, {
propsData: { init: false }
})
expect(wrapper.find('img').isVisible()).to.equal(false)
})
it('gets init state according to passed props', () => {
const wrapperChecked = shallowMount(CheckBox, {
propsData: { init: true }
})
expect(wrapperChecked.find('img').isVisible()).to.equal(true)
const wrapperUnchecked = shallowMount(CheckBox, {
propsData: { init: false }
})
expect(wrapperUnchecked.find('img').isVisible()).to.equal(false)
})
it('checked on click', async () => {
const wrapper = shallowMount(CheckBox)
await wrapper.trigger('click')
expect(wrapper.find('img').isVisible()).to.equal(true)
})
it('emits event on click', async () => {
const wrapper = shallowMount(CheckBox)
await wrapper.trigger('click')
expect(wrapper.emitted().click.length).to.equal(1)
expect(wrapper.emitted().click[0]).to.eql([true])
await wrapper.trigger('click')
expect(wrapper.emitted().click.length).to.equal(2)
expect(wrapper.emitted().click[1]).to.eql([false])
})
})