1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2026-02-04 15:38:55 +08:00

change repo structure

This commit is contained in:
lana-k
2026-01-15 21:53:12 +01:00
parent 85b5a200e2
commit 7edc196a02
64 changed files with 74 additions and 74 deletions

View File

@@ -0,0 +1,61 @@
import { expect } from 'chai'
import { mount } from '@vue/test-utils'
import { createStore } from 'vuex'
import SqlEditor from '@/components/SqlEditor'
import { nextTick } from 'vue'
describe('SqlEditor.vue', () => {
it('Emits update:modelValue event when a query is changed', async () => {
// mock store state
const state = {
db: {}
}
const store = createStore({ state })
const wrapper = mount(SqlEditor, {
global: {
plugins: [store]
}
})
await wrapper
.findComponent({ ref: 'cm' })
.setValue('SELECT * FROM foo', 'value')
expect(wrapper.emitted()['update:modelValue'][0]).to.eql([
'SELECT * FROM foo'
])
})
it('Run is disabled if there is no db or no query or is getting result set', async () => {
const state = {
db: null
}
const store = createStore({ state })
const wrapper = mount(SqlEditor, {
global: { plugins: [store] },
props: { isGettingResults: false }
})
await wrapper
.findComponent({ ref: 'cm' })
.setValue('SELECT * FROM foo', 'value')
const runButton = wrapper.findComponent({ ref: 'runBtn' })
expect(runButton.props('disabled')).to.equal(true)
store.state.db = {}
await nextTick()
expect(runButton.props('disabled')).to.equal(false)
await wrapper.findComponent({ ref: 'cm' }).setValue('', 'value')
expect(runButton.props('disabled')).to.equal(true)
await wrapper
.findComponent({ ref: 'cm' })
.setValue('SELECT * FROM foo', 'value')
expect(runButton.props('disabled')).to.equal(false)
await wrapper.setProps({ isGettingResults: true })
expect(runButton.props('disabled')).to.equal(true)
})
})