mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
add checkBox tests
This commit is contained in:
@@ -2,12 +2,10 @@
|
||||
<div class="checkbox-container" @click.stop="onClick">
|
||||
<div v-show="!checked" class="unchecked" />
|
||||
<img
|
||||
v-show="checked && theme === 'accent'"
|
||||
:src="require('@/assets/images/checkbox_checked.svg')"
|
||||
/>
|
||||
<img
|
||||
v-show="checked && theme === 'light'"
|
||||
:src="require('@/assets/images/checkbox_checked_light.svg')"
|
||||
v-show="checked"
|
||||
:src="theme === 'light'
|
||||
? require('@/assets/images/checkbox_checked_light.svg')
|
||||
: require('@/assets/images/checkbox_checked.svg')"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
39
tests/unit/checkBox.spec.js
Normal file
39
tests/unit/checkBox.spec.js
Normal 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])
|
||||
})
|
||||
})
|
||||
@@ -1,17 +1,3 @@
|
||||
/* import { expect } from 'chai'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import HelloWorld from '@/components/HelloWorld.vue'
|
||||
|
||||
describe('HelloWorld.vue', () => {
|
||||
it('renders props.msg when passed', () => {
|
||||
const msg = 'new message'
|
||||
const wrapper = shallowMount(HelloWorld, {
|
||||
propsData: { msg }
|
||||
})
|
||||
expect(wrapper.text()).to.include(msg)
|
||||
})
|
||||
})
|
||||
*/
|
||||
import { expect } from 'chai'
|
||||
import initSqlJs from 'sql.js'
|
||||
import db from '@/database.js'
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('mutations', () => {
|
||||
schema
|
||||
})
|
||||
expect(state.dbName).to.equal('test')
|
||||
expect(JSON.stringify(state.schema)).to.equal(JSON.stringify(schema))
|
||||
expect(state.schema).to.eql(schema)
|
||||
})
|
||||
|
||||
it('addTab (new)', () => {
|
||||
@@ -44,7 +44,7 @@ describe('mutations', () => {
|
||||
isUnsaved: true
|
||||
}
|
||||
addTab(state, tab)
|
||||
expect(JSON.stringify(state.tabs[0])).to.equal(JSON.stringify(tab))
|
||||
expect(state.tabs[0]).to.eql(tab)
|
||||
expect(state.untitledLastIndex).to.equal(1)
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('mutations', () => {
|
||||
isUnsaved: false
|
||||
}
|
||||
addTab(state, tab)
|
||||
expect(JSON.stringify(state.tabs[0])).to.equal(JSON.stringify(tab))
|
||||
expect(state.tabs[0]).to.eql(tab)
|
||||
expect(state.untitledLastIndex).to.equal(0)
|
||||
})
|
||||
|
||||
@@ -395,7 +395,7 @@ describe('mutations', () => {
|
||||
}
|
||||
|
||||
setCurrentTab(state, { id: 2 })
|
||||
expect(JSON.stringify(state.currentTab)).to.equal('{"id":2}')
|
||||
expect(state.currentTab).to.eql({ id: 2 })
|
||||
})
|
||||
|
||||
it('updatePredefinedQueries (single)', () => {
|
||||
@@ -412,7 +412,7 @@ describe('mutations', () => {
|
||||
}
|
||||
|
||||
updatePredefinedQueries(state, query)
|
||||
expect(JSON.stringify(state.predefinedQueries)).to.equal(`[${JSON.stringify(query)}]`)
|
||||
expect(state.predefinedQueries).to.eql([query])
|
||||
})
|
||||
|
||||
it('updatePredefinedQueries (array)', () => {
|
||||
@@ -436,6 +436,6 @@ describe('mutations', () => {
|
||||
}
|
||||
|
||||
updatePredefinedQueries(state, queries)
|
||||
expect(JSON.stringify(state.predefinedQueries)).to.equal(JSON.stringify(queries))
|
||||
expect(state.predefinedQueries).to.eql(queries)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user