mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
format
This commit is contained in:
@@ -13,16 +13,16 @@ describe('App.vue', () => {
|
||||
})
|
||||
|
||||
it('Gets inquiries', () => {
|
||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||
{ id: 1 }, { id: 2 }, { id: 3 }
|
||||
])
|
||||
sinon
|
||||
.stub(storedInquiries, 'getStoredInquiries')
|
||||
.returns([{ id: 1 }, { id: 2 }, { id: 3 }])
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: []
|
||||
}
|
||||
const store = createStore({ state, mutations })
|
||||
shallowMount(App, {
|
||||
global: {
|
||||
global: {
|
||||
stubs: ['router-view'],
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -33,7 +33,9 @@ describe('App.vue', () => {
|
||||
|
||||
it('Updates inquiries when they change in store', async () => {
|
||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||
{ id: 1, name: 'foo' }, { id: 2, name: 'baz' }, { id: 3, name: 'bar' }
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'baz' },
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
sinon.spy(storedInquiries, 'updateStorage')
|
||||
|
||||
@@ -43,8 +45,7 @@ describe('App.vue', () => {
|
||||
}
|
||||
const store = createStore({ state, mutations })
|
||||
shallowMount(App, {
|
||||
global: { stubs: ['router-view'],
|
||||
plugins: [store] }
|
||||
global: { stubs: ['router-view'], plugins: [store] }
|
||||
})
|
||||
|
||||
store.state.inquiries.splice(0, 1, { id: 1, name: 'new foo name' })
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('CheckBox', () => {
|
||||
})
|
||||
expect(wrapperChecked.find('img.checked').isVisible()).to.equal(true)
|
||||
wrapperChecked.unmount()
|
||||
|
||||
|
||||
const wrapperUnchecked = shallowMount(CheckBox, {
|
||||
props: { init: false },
|
||||
attachTo: document.body
|
||||
@@ -50,9 +50,13 @@ describe('CheckBox', () => {
|
||||
props: { disabled: true }
|
||||
})
|
||||
expect(wrapper.find('.checkbox-container').classes()).to.include('disabled')
|
||||
expect(wrapper.find('.checkbox-container').classes()).to.not.include('checked')
|
||||
expect(wrapper.find('.checkbox-container').classes()).to.not.include(
|
||||
'checked'
|
||||
)
|
||||
await wrapper.trigger('click')
|
||||
expect(wrapper.emitted().click).to.equal(undefined)
|
||||
expect(wrapper.find('.checkbox-container').classes()).to.not.include('checked')
|
||||
expect(wrapper.find('.checkbox-container').classes()).to.not.include(
|
||||
'checked'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -6,7 +6,6 @@ import CsvJsonImport from '@/components/CsvJsonImport'
|
||||
import csv from '@/lib/csv'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
|
||||
describe('CsvJsonImport.vue', () => {
|
||||
let state = {}
|
||||
let actions = {}
|
||||
@@ -74,13 +73,15 @@ describe('CsvJsonImport.vue', () => {
|
||||
}
|
||||
},
|
||||
rowCount: 2,
|
||||
messages: [{
|
||||
code: 'UndetectableDelimiter',
|
||||
message: 'Comma was used as a standart delimiter',
|
||||
row: 0,
|
||||
type: 'info',
|
||||
hint: undefined
|
||||
}]
|
||||
messages: [
|
||||
{
|
||||
code: 'UndetectableDelimiter',
|
||||
message: 'Comma was used as a standart delimiter',
|
||||
row: 0,
|
||||
type: 'info',
|
||||
hint: undefined
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
wrapper.vm.preview()
|
||||
@@ -89,24 +90,34 @@ describe('CsvJsonImport.vue', () => {
|
||||
await nextTick()
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog-header').text()).to.equal('CSV import')
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal('my_data')
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).props('modelValue')).to.equal('|')
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal(
|
||||
'my_data'
|
||||
)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).props('modelValue')
|
||||
).to.equal('|')
|
||||
expect(wrapper.find('#quote-char input').element.value).to.equal('"')
|
||||
expect(wrapper.find('#escape-char input').element.value).to.equal('"')
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.checked).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.checked).to.equal(
|
||||
true
|
||||
)
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(2)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('foo')
|
||||
expect(rows[0].findAll('td')[1].text()).to.equal('1')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equal('bar')
|
||||
expect(rows[1].findAll('td')[1].text()).to.equal('2')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Information about row 0. Comma was used as a standart delimiter.')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Preview parsing is completed in')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Information about row 0. Comma was used as a standart delimiter.'
|
||||
)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
expect(wrapper.find('#import-start').attributes().disabled).to.equal(undefined)
|
||||
expect(wrapper.find('#import-start').attributes().disabled).to.equal(
|
||||
undefined
|
||||
)
|
||||
})
|
||||
|
||||
it('disables import if no rows found', async () => {
|
||||
@@ -129,8 +140,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
await nextTick()
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(0)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('No rows to import.')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'No rows to import.'
|
||||
)
|
||||
expect(wrapper.find('.no-data').isVisible()).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
@@ -177,8 +189,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(rows).to.have.lengthOf(1)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('bar')
|
||||
expect(rows[0].findAll('td')[1].text()).to.equal('2')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Preview parsing is completed in')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
|
||||
parse.onCall(2).resolves({
|
||||
delimiter: ',',
|
||||
@@ -191,13 +204,15 @@ describe('CsvJsonImport.vue', () => {
|
||||
},
|
||||
rowCount: 1,
|
||||
hasErrors: true,
|
||||
messages: [{
|
||||
code: 'MissingQuotes',
|
||||
message: 'Quote is missed',
|
||||
row: 0,
|
||||
type: 'error',
|
||||
hint: 'Edit your CSV so that the field has a closing quote char.'
|
||||
}]
|
||||
messages: [
|
||||
{
|
||||
code: 'MissingQuotes',
|
||||
message: 'Quote is missed',
|
||||
row: 0,
|
||||
type: 'error',
|
||||
hint: 'Edit your CSV so that the field has a closing quote char.'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await wrapper.find('#quote-char input').setValue("'")
|
||||
@@ -207,13 +222,13 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(rows).to.have.lengthOf(1)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('baz')
|
||||
expect(rows[0].findAll('td')[1].text()).to.equal('3')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.contain(
|
||||
'Error in row 0. Quote is missed. ' +
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.contain(
|
||||
'Error in row 0. Quote is missed. ' +
|
||||
'Edit your CSV so that the field has a closing quote char.'
|
||||
)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.not.contain('Preview parsing is completed in')
|
||||
)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.not.contain(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
|
||||
parse.onCall(3).resolves({
|
||||
delimiter: ',',
|
||||
@@ -234,8 +249,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(rows).to.have.lengthOf(1)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('qux')
|
||||
expect(rows[0].findAll('td')[1].text()).to.equal('4')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.contain('Preview parsing is completed in')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.contain(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
|
||||
parse.onCall(4).resolves({
|
||||
delimiter: ',',
|
||||
@@ -257,8 +273,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('corge')
|
||||
expect(rows[0].findAll('td')[1].text()).to.equal('5')
|
||||
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Preview parsing is completed in')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
})
|
||||
|
||||
it('has proper state before parsing is complete', async () => {
|
||||
@@ -282,42 +299,55 @@ describe('CsvJsonImport.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
let resolveParsing
|
||||
parse.onCall(1).returns(new Promise(resolve => {
|
||||
resolveParsing = () => resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['col1', 'col2'],
|
||||
values: {
|
||||
col1: [1],
|
||||
col2: ['foo']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
messages: []
|
||||
parse.onCall(1).returns(
|
||||
new Promise(resolve => {
|
||||
resolveParsing = () =>
|
||||
resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['col1', 'col2'],
|
||||
values: {
|
||||
col1: [1],
|
||||
col2: ['foo']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
messages: []
|
||||
})
|
||||
})
|
||||
}))
|
||||
)
|
||||
|
||||
await wrapper.find('#csv-json-table-name input').setValue('foo')
|
||||
await wrapper.find('#import-start').trigger('click')
|
||||
|
||||
// "Parsing CSV..." in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text())
|
||||
.to.equal('Parsing CSV...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text()
|
||||
).to.equal('Parsing CSV...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(true)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(true)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
await resolveParsing()
|
||||
@@ -325,7 +355,10 @@ describe('CsvJsonImport.vue', () => {
|
||||
|
||||
// Loading indicator is not shown when parsing is compete
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -365,26 +398,35 @@ describe('CsvJsonImport.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
let resolveImport
|
||||
wrapper.vm.db.addTableFromCsv.onCall(0).returns(new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
}))
|
||||
wrapper.vm.db.addTableFromCsv.onCall(0).returns(
|
||||
new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
})
|
||||
)
|
||||
|
||||
await wrapper.find('#csv-json-table-name input').setValue('foo')
|
||||
await wrapper.find('#import-start').trigger('click')
|
||||
await csv.parse.returnValues[1]
|
||||
|
||||
// Parsing success in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text())
|
||||
.to.include('2 rows are parsed successfully in')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text()
|
||||
).to.include('2 rows are parsed successfully in')
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(true)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(true)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
await resolveImport()
|
||||
@@ -417,18 +459,22 @@ describe('CsvJsonImport.vue', () => {
|
||||
},
|
||||
rowCount: 2,
|
||||
hasErrors: false,
|
||||
messages: [{
|
||||
code: 'UndetectableDelimiter',
|
||||
message: 'Comma was used as a standart delimiter',
|
||||
type: 'info',
|
||||
hint: undefined
|
||||
}]
|
||||
messages: [
|
||||
{
|
||||
code: 'UndetectableDelimiter',
|
||||
message: 'Comma was used as a standart delimiter',
|
||||
type: 'info',
|
||||
hint: undefined
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
let resolveImport
|
||||
wrapper.vm.db.addTableFromCsv.onCall(0).returns(new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
}))
|
||||
wrapper.vm.db.addTableFromCsv.onCall(0).returns(
|
||||
new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
})
|
||||
)
|
||||
|
||||
wrapper.vm.preview()
|
||||
wrapper.vm.open()
|
||||
@@ -446,13 +492,19 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(logs[2].text()).to.equals('Comma was used as a standart delimiter.')
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(true)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(true)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
await resolveImport()
|
||||
@@ -485,12 +537,14 @@ describe('CsvJsonImport.vue', () => {
|
||||
},
|
||||
rowCount: 2,
|
||||
hasErrors: true,
|
||||
messages: [{
|
||||
code: 'Error',
|
||||
message: 'Something is wrong',
|
||||
type: 'error',
|
||||
hint: undefined
|
||||
}]
|
||||
messages: [
|
||||
{
|
||||
code: 'Error',
|
||||
message: 'Something is wrong',
|
||||
type: 'error',
|
||||
hint: undefined
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
wrapper.vm.preview()
|
||||
@@ -509,13 +563,19 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(logs[2].text()).to.equals('Something is wrong.')
|
||||
|
||||
// All the dialog controls are enabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(false)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(false)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
})
|
||||
@@ -551,8 +611,11 @@ describe('CsvJsonImport.vue', () => {
|
||||
})
|
||||
|
||||
let resolveImport = sinon.stub()
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub()
|
||||
.resolves(new Promise(resolve => { resolveImport = resolve }))
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub().resolves(
|
||||
new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
})
|
||||
)
|
||||
|
||||
wrapper.vm.preview()
|
||||
wrapper.vm.open()
|
||||
@@ -564,23 +627,33 @@ describe('CsvJsonImport.vue', () => {
|
||||
await csv.parse.returnValues[1]
|
||||
|
||||
// Parsing success in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text())
|
||||
.to.equal('Importing CSV into a SQLite database...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text()
|
||||
).to.equal('Importing CSV into a SQLite database...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(true)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(true)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
expect(wrapper.vm.db.addTableFromCsv.getCall(0).args[0]).to.equal('foo') // table name
|
||||
@@ -589,7 +662,10 @@ describe('CsvJsonImport.vue', () => {
|
||||
await resolveImport()
|
||||
await wrapper.vm.db.addTableFromCsv.returnValues[0]
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -635,16 +711,24 @@ describe('CsvJsonImport.vue', () => {
|
||||
// Import success in the logs
|
||||
const logs = wrapper.findComponent({ name: 'logs' }).findAll('.msg')
|
||||
expect(logs).to.have.lengthOf(3)
|
||||
expect(logs[2].text()).to.contain('Importing CSV into a SQLite database is completed in')
|
||||
expect(logs[2].text()).to.contain(
|
||||
'Importing CSV into a SQLite database is completed in'
|
||||
)
|
||||
|
||||
// All the dialog controls are enabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(false)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(false)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(true)
|
||||
})
|
||||
|
||||
@@ -696,13 +780,19 @@ describe('CsvJsonImport.vue', () => {
|
||||
expect(logs[3].text()).to.equal('Error: fail.')
|
||||
|
||||
// All the dialog controls are enabled
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled).to.equal(false)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).vm.disabled
|
||||
).to.equal(false)
|
||||
expect(wrapper.find('#quote-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#escape-char input').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -733,7 +823,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
await clock.tick(100)
|
||||
expect(actions.addTab.calledOnce).to.equal(true)
|
||||
await actions.addTab.returnValues[0]
|
||||
expect(mutations.setCurrentTabId.calledOnceWith(state, newTabId)).to.equal(true)
|
||||
expect(mutations.setCurrentTabId.calledOnceWith(state, newTabId)).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
expect(wrapper.emitted('finish')).to.have.lengthOf(1)
|
||||
})
|
||||
@@ -764,7 +856,9 @@ describe('CsvJsonImport.vue', () => {
|
||||
await wrapper.find('#import-cancel').trigger('click')
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
expect(wrapper.vm.db.execute.calledOnceWith('DROP TABLE "my_data"')).to.equal(true)
|
||||
expect(
|
||||
wrapper.vm.db.execute.calledOnceWith('DROP TABLE "my_data"')
|
||||
).to.equal(true)
|
||||
expect(wrapper.vm.db.refreshSchema.calledOnce).to.equal(true)
|
||||
expect(wrapper.emitted('cancel')).to.have.lengthOf(1)
|
||||
})
|
||||
@@ -783,23 +877,31 @@ describe('CsvJsonImport.vue', () => {
|
||||
await wrapper.find('#csv-json-table-name input').setValue('foo')
|
||||
await clock.tick(400)
|
||||
await nextTick()
|
||||
expect(wrapper.find('#csv-json-table-name .text-field-error').text()).to.equal('')
|
||||
expect(
|
||||
wrapper.find('#csv-json-table-name .text-field-error').text()
|
||||
).to.equal('')
|
||||
|
||||
wrapper.vm.db.validateTableName = sinon.stub().rejects(new Error('this is a bad table name'))
|
||||
wrapper.vm.db.validateTableName = sinon
|
||||
.stub()
|
||||
.rejects(new Error('this is a bad table name'))
|
||||
await wrapper.find('#csv-json-table-name input').setValue('bar')
|
||||
await clock.tick(400)
|
||||
await nextTick()
|
||||
expect(wrapper.find('#csv-json-table-name .text-field-error').text())
|
||||
.to.equal('this is a bad table name. Try another table name.')
|
||||
expect(
|
||||
wrapper.find('#csv-json-table-name .text-field-error').text()
|
||||
).to.equal('this is a bad table name. Try another table name.')
|
||||
|
||||
await wrapper.find('#csv-json-table-name input').setValue('')
|
||||
await clock.tick(400)
|
||||
await nextTick()
|
||||
expect(wrapper.find('#csv-json-table-name .text-field-error').text()).to.equal('')
|
||||
expect(
|
||||
wrapper.find('#csv-json-table-name .text-field-error').text()
|
||||
).to.equal('')
|
||||
|
||||
await wrapper.find('#import-start').trigger('click')
|
||||
expect(wrapper.find('#csv-json-table-name .text-field-error').text())
|
||||
.to.equal("Table name can't be empty")
|
||||
expect(
|
||||
wrapper.find('#csv-json-table-name .text-field-error').text()
|
||||
).to.equal("Table name can't be empty")
|
||||
expect(wrapper.vm.db.addTableFromCsv.called).to.equal(false)
|
||||
})
|
||||
})
|
||||
@@ -812,12 +914,14 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
let wrapper
|
||||
const newTabId = 1
|
||||
const file = new File(
|
||||
[new Blob(
|
||||
[JSON.stringify({ foo: [1, 2, 3] }, null, 2)],
|
||||
{ type: 'application/json' }
|
||||
)],
|
||||
[
|
||||
new Blob([JSON.stringify({ foo: [1, 2, 3] }, null, 2)], {
|
||||
type: 'application/json'
|
||||
})
|
||||
],
|
||||
'my data.json',
|
||||
{ type: 'application/json' })
|
||||
{ type: 'application/json' }
|
||||
)
|
||||
|
||||
beforeEach(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
@@ -845,7 +949,7 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
|
||||
// mount the component
|
||||
wrapper = mount(CsvJsonImport, {
|
||||
global: {
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: {
|
||||
teleport: true,
|
||||
@@ -873,25 +977,25 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
await nextTick()
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog-header').text()).to.equal('JSON import')
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal('my_data')
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).exists()).to.equal(false)
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal(
|
||||
'my_data'
|
||||
)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).exists()
|
||||
).to.equal(false)
|
||||
expect(wrapper.find('#quote-char input').exists()).to.equal(false)
|
||||
expect(wrapper.find('#escape-char input').exists()).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).exists()).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).exists()).to.equal(
|
||||
false
|
||||
)
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(1)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal([
|
||||
'{',
|
||||
' "foo": [',
|
||||
' 1,',
|
||||
' 2,',
|
||||
' 3',
|
||||
' ]',
|
||||
'}'
|
||||
].join('\n')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal(
|
||||
['{', ' "foo": [', ' 1,', ' 2,', ' 3', ' ]', '}'].join('\n')
|
||||
)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Preview parsing is completed in')
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
})
|
||||
@@ -912,20 +1016,23 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
})
|
||||
|
||||
let resolveParsing
|
||||
getJsonParseResult.onCall(1).returns(new Promise(resolve => {
|
||||
resolveParsing = () => resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['doc'],
|
||||
values: {
|
||||
doc: ['{ "foo": [ 1, 2, 3 ] }']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
hasErrors: false,
|
||||
messages: []
|
||||
getJsonParseResult.onCall(1).returns(
|
||||
new Promise(resolve => {
|
||||
resolveParsing = () =>
|
||||
resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['doc'],
|
||||
values: {
|
||||
doc: ['{ "foo": [ 1, 2, 3 ] }']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
hasErrors: false,
|
||||
messages: []
|
||||
})
|
||||
})
|
||||
}))
|
||||
)
|
||||
|
||||
await wrapper.vm.preview()
|
||||
await wrapper.vm.open()
|
||||
@@ -937,19 +1044,25 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
await nextTick()
|
||||
|
||||
// "Parsing JSON..." in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text())
|
||||
.to.equal('Parsing JSON...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text()
|
||||
).to.equal('Parsing JSON...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
await resolveParsing()
|
||||
@@ -957,7 +1070,10 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
|
||||
// Loading indicator is not shown when parsing is compete
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -965,8 +1081,11 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
const getJsonParseResult = sinon.spy(wrapper.vm, 'getJsonParseResult')
|
||||
|
||||
let resolveImport = sinon.stub()
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub()
|
||||
.resolves(new Promise(resolve => { resolveImport = resolve }))
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub().resolves(
|
||||
new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
})
|
||||
)
|
||||
|
||||
await wrapper.vm.preview()
|
||||
await wrapper.vm.open()
|
||||
@@ -979,19 +1098,25 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
await nextTick()
|
||||
|
||||
// Parsing success in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text())
|
||||
.to.equal('Importing JSON into a SQLite database...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text()
|
||||
).to.equal('Importing JSON into a SQLite database...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
expect(wrapper.vm.db.addTableFromCsv.getCall(0).args[0]).to.equal('foo') // table name
|
||||
@@ -1000,7 +1125,10 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
await resolveImport()
|
||||
await wrapper.vm.db.addTableFromCsv.returnValues[0]
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -1021,12 +1149,16 @@ describe('CsvJsonImport.vue - json', () => {
|
||||
// Import success in the logs
|
||||
const logs = wrapper.findComponent({ name: 'logs' }).findAll('.msg')
|
||||
expect(logs).to.have.lengthOf(3)
|
||||
expect(logs[2].text()).to.contain('Importing JSON into a SQLite database is completed in')
|
||||
expect(logs[2].text()).to.contain(
|
||||
'Importing JSON into a SQLite database is completed in'
|
||||
)
|
||||
|
||||
// All the dialog controls are enabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(true)
|
||||
})
|
||||
})
|
||||
@@ -1106,16 +1238,23 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
await nextTick()
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog-header').text()).to.equal('JSON import')
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal('my_data')
|
||||
expect(wrapper.findComponent({ name: 'delimiter-selector' }).exists()).to.equal(false)
|
||||
expect(wrapper.find('#csv-json-table-name input').element.value).to.equal(
|
||||
'my_data'
|
||||
)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'delimiter-selector' }).exists()
|
||||
).to.equal(false)
|
||||
expect(wrapper.find('#quote-char input').exists()).to.equal(false)
|
||||
expect(wrapper.find('#escape-char input').exists()).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).exists()).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'check-box' }).exists()).to.equal(
|
||||
false
|
||||
)
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(1)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equal('{ "foo": [ 1, 2, 3 ] }')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text())
|
||||
.to.include('Preview parsing is completed in')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'Preview parsing is completed in'
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
})
|
||||
@@ -1139,38 +1278,47 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
await nextTick()
|
||||
|
||||
let resolveParsing
|
||||
parse.onCall(1).returns(new Promise(resolve => {
|
||||
resolveParsing = () => resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['doc'],
|
||||
values: {
|
||||
doc: ['{ "foo": [ 1, 2, 3 ] }']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
messages: []
|
||||
parse.onCall(1).returns(
|
||||
new Promise(resolve => {
|
||||
resolveParsing = () =>
|
||||
resolve({
|
||||
delimiter: '|',
|
||||
data: {
|
||||
columns: ['doc'],
|
||||
values: {
|
||||
doc: ['{ "foo": [ 1, 2, 3 ] }']
|
||||
}
|
||||
},
|
||||
rowCount: 1,
|
||||
messages: []
|
||||
})
|
||||
})
|
||||
}))
|
||||
)
|
||||
|
||||
await wrapper.find('#csv-json-table-name input').setValue('foo')
|
||||
await wrapper.find('#import-start').trigger('click')
|
||||
await nextTick()
|
||||
|
||||
// "Parsing JSON..." in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text())
|
||||
.to.equal('Parsing JSON...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[1].text()
|
||||
).to.equal('Parsing JSON...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
await resolveParsing()
|
||||
@@ -1178,7 +1326,10 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
|
||||
// Loading indicator is not shown when parsing is compete
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -1211,8 +1362,11 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
})
|
||||
|
||||
let resolveImport = sinon.stub()
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub()
|
||||
.resolves(new Promise(resolve => { resolveImport = resolve }))
|
||||
wrapper.vm.db.addTableFromCsv = sinon.stub().resolves(
|
||||
new Promise(resolve => {
|
||||
resolveImport = resolve
|
||||
})
|
||||
)
|
||||
|
||||
wrapper.vm.preview()
|
||||
wrapper.vm.open()
|
||||
@@ -1225,19 +1379,25 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
await nextTick()
|
||||
|
||||
// Parsing success in the logs
|
||||
expect(wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text())
|
||||
.to.equal('Importing JSON into a SQLite database...')
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findAll('.msg')[2].text()
|
||||
).to.equal('Importing JSON into a SQLite database...')
|
||||
|
||||
// After 1 second - loading indicator is shown
|
||||
await clock.tick(1000)
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(true)
|
||||
|
||||
// All the dialog controls are disabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(true)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('#import-start').isVisible()).to.equal(true)
|
||||
expect(wrapper.vm.db.addTableFromCsv.getCall(0).args[0]).to.equal('foo') // table name
|
||||
@@ -1246,7 +1406,10 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
await resolveImport()
|
||||
await wrapper.vm.db.addTableFromCsv.returnValues[0]
|
||||
expect(
|
||||
wrapper.findComponent({ name: 'logs' }).findComponent({ name: 'LoadingIndicator' }).exists()
|
||||
wrapper
|
||||
.findComponent({ name: 'logs' })
|
||||
.findComponent({ name: 'LoadingIndicator' })
|
||||
.exists()
|
||||
).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -1291,12 +1454,16 @@ describe('CsvJsonImport.vue - ndjson', () => {
|
||||
// Import success in the logs
|
||||
const logs = wrapper.findComponent({ name: 'logs' }).findAll('.msg')
|
||||
expect(logs).to.have.lengthOf(3)
|
||||
expect(logs[2].text()).to.contain('Importing JSON into a SQLite database is completed in')
|
||||
expect(logs[2].text()).to.contain(
|
||||
'Importing JSON into a SQLite database is completed in'
|
||||
)
|
||||
|
||||
// All the dialog controls are enabled
|
||||
expect(wrapper.find('#import-cancel').element.disabled).to.equal(false)
|
||||
expect(wrapper.find('#import-finish').element.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'close-icon' }).vm.disabled).to.equal(
|
||||
false
|
||||
)
|
||||
expect(wrapper.find('#import-finish').isVisible()).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -37,9 +37,9 @@ describe('DelimiterSelector', async () => {
|
||||
|
||||
it('changes value by typing', async () => {
|
||||
const wrapper = shallowMount(DelimiterSelector, {
|
||||
props: {
|
||||
props: {
|
||||
modelValue: ',',
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('DelimiterSelector', async () => {
|
||||
const wrapper = mount(DelimiterSelector, {
|
||||
props: {
|
||||
modelValue: '|',
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
},
|
||||
attachTo: document.body
|
||||
})
|
||||
@@ -66,9 +66,9 @@ describe('DelimiterSelector', async () => {
|
||||
|
||||
it("doesn't change value when becomes empty", async () => {
|
||||
const wrapper = mount(DelimiterSelector, {
|
||||
props: {
|
||||
props: {
|
||||
modelValue: '|',
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -96,7 +96,7 @@ describe('DelimiterSelector', async () => {
|
||||
props: {
|
||||
modelValue: '|',
|
||||
disabled: true,
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
},
|
||||
attachTo: document.body
|
||||
})
|
||||
|
||||
@@ -7,7 +7,6 @@ import fu from '@/lib/utils/fileIo'
|
||||
import database from '@/lib/database'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
|
||||
describe('DbUploader.vue', () => {
|
||||
let state = {}
|
||||
let mutations = {}
|
||||
|
||||
@@ -19,7 +19,8 @@ describe('LoadingIndicator.vue', () => {
|
||||
})
|
||||
// The lendth of circle in the component is 50.24. If progress is 50% then resulting arc
|
||||
// should be 25.12
|
||||
expect(wrapper.find('.loader-svg.front').element.style.strokeDasharray)
|
||||
.to.equal('25.12px, 25.12px')
|
||||
expect(
|
||||
wrapper.find('.loader-svg.front').element.style.strokeDasharray
|
||||
).to.equal('25.12px, 25.12px')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -31,8 +31,9 @@ describe('Logs.vue', () => {
|
||||
})
|
||||
await nextTick()
|
||||
const height = wrapper.find('.logs-container').element.scrollHeight
|
||||
expect(wrapper.find('.logs-container').element.scrollTop)
|
||||
.to.equal(height - viewHeight)
|
||||
expect(wrapper.find('.logs-container').element.scrollTop).to.equal(
|
||||
height - viewHeight
|
||||
)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -58,8 +59,9 @@ describe('Logs.vue', () => {
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
const height = wrapper.find('.logs-container').element.scrollHeight
|
||||
expect(wrapper.find('.logs-container').element.scrollTop)
|
||||
.to.equal(height - viewHeight)
|
||||
expect(wrapper.find('.logs-container').element.scrollTop).to.equal(
|
||||
height - viewHeight
|
||||
)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
|
||||
@@ -18,8 +18,12 @@ describe('Splitpanes.vue', () => {
|
||||
})
|
||||
|
||||
expect(wrapper.findAll('.splitpanes-pane')).to.have.lengthOf(2)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('60%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('40%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'60%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'40%'
|
||||
)
|
||||
})
|
||||
|
||||
it('renders correctly - horizontal', () => {
|
||||
@@ -37,8 +41,12 @@ describe('Splitpanes.vue', () => {
|
||||
})
|
||||
|
||||
expect(wrapper.findAll('.splitpanes-pane')).to.have.lengthOf(2)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.height).to.equal('60%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.height).to.equal('40%')
|
||||
expect(
|
||||
wrapper.findAll('.splitpanes-pane')[0].element.style.height
|
||||
).to.equal('60%')
|
||||
expect(
|
||||
wrapper.findAll('.splitpanes-pane')[1].element.style.height
|
||||
).to.equal('40%')
|
||||
})
|
||||
|
||||
it('toggles correctly - no maximized initially', async () => {
|
||||
@@ -55,20 +63,36 @@ describe('Splitpanes.vue', () => {
|
||||
})
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('60%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('40%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'60%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'40%'
|
||||
)
|
||||
|
||||
await wrapper.findAll('.toggle-btn')[1].trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('60%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('40%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'60%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'40%'
|
||||
)
|
||||
})
|
||||
|
||||
it('toggles correctly - with maximized initially', async () => {
|
||||
@@ -86,20 +110,36 @@ describe('Splitpanes.vue', () => {
|
||||
})
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('20%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('80%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'20%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'80%'
|
||||
)
|
||||
|
||||
await wrapper.findAll('.toggle-btn')[0].trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('20%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('80%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'20%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'80%'
|
||||
)
|
||||
|
||||
await wrapper.findAll('.toggle-btn')[1].trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
|
||||
wrapper = shallowMount(Splitpanes, {
|
||||
slots: {
|
||||
@@ -113,20 +153,36 @@ describe('Splitpanes.vue', () => {
|
||||
})
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
|
||||
await wrapper.findAll('.toggle-btn')[0].trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
|
||||
await wrapper.find('.toggle-btn').trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
|
||||
await wrapper.findAll('.toggle-btn')[1].trigger('click')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('100%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal('0%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'100%'
|
||||
)
|
||||
expect(wrapper.findAll('.splitpanes-pane')[1].element.style.width).to.equal(
|
||||
'0%'
|
||||
)
|
||||
})
|
||||
|
||||
it('drag - vertical', async () => {
|
||||
@@ -151,13 +207,17 @@ describe('Splitpanes.vue', () => {
|
||||
parent.style.height = '500px'
|
||||
|
||||
await wrapper.find('.splitpanes-splitter').trigger('mousedown')
|
||||
document.dispatchEvent(new MouseEvent('mousemove', {
|
||||
clientX: 300,
|
||||
clientY: 80
|
||||
}))
|
||||
document.dispatchEvent(
|
||||
new MouseEvent('mousemove', {
|
||||
clientX: 300,
|
||||
clientY: 80
|
||||
})
|
||||
)
|
||||
document.dispatchEvent(new MouseEvent('mouseup'))
|
||||
await nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
wrapper.unmount()
|
||||
root.remove()
|
||||
})
|
||||
@@ -186,14 +246,18 @@ describe('Splitpanes.vue', () => {
|
||||
parent.style.height = '500px'
|
||||
|
||||
await wrapper.find('.splitpanes-splitter').trigger('mousedown')
|
||||
document.dispatchEvent(new MouseEvent('mousemove', {
|
||||
clientX: 10,
|
||||
clientY: 250
|
||||
}))
|
||||
document.dispatchEvent(
|
||||
new MouseEvent('mousemove', {
|
||||
clientX: 10,
|
||||
clientY: 250
|
||||
})
|
||||
)
|
||||
document.dispatchEvent(new MouseEvent('mouseup'))
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.height).to.equal('50%')
|
||||
expect(
|
||||
wrapper.findAll('.splitpanes-pane')[0].element.style.height
|
||||
).to.equal('50%')
|
||||
wrapper.unmount()
|
||||
root.remove()
|
||||
})
|
||||
@@ -225,16 +289,20 @@ describe('Splitpanes.vue', () => {
|
||||
await wrapper.find('.splitpanes-splitter').trigger('touchstart')
|
||||
const event = new TouchEvent('touchmove')
|
||||
Object.defineProperty(event, 'touches', {
|
||||
value: [{
|
||||
clientX: 10,
|
||||
clientY: 250
|
||||
}],
|
||||
value: [
|
||||
{
|
||||
clientX: 10,
|
||||
clientY: 250
|
||||
}
|
||||
],
|
||||
writable: true
|
||||
})
|
||||
document.dispatchEvent(event)
|
||||
document.dispatchEvent(new MouseEvent('touchend'))
|
||||
await nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.height).to.equal('50%')
|
||||
expect(
|
||||
wrapper.findAll('.splitpanes-pane')[0].element.style.height
|
||||
).to.equal('50%')
|
||||
wrapper.unmount()
|
||||
root.remove()
|
||||
delete window.ontouchstart
|
||||
@@ -265,16 +333,20 @@ describe('Splitpanes.vue', () => {
|
||||
await wrapper.find('.splitpanes-splitter').trigger('touchstart')
|
||||
const event = new TouchEvent('touchmove')
|
||||
Object.defineProperty(event, 'touches', {
|
||||
value: [{
|
||||
clientX: 300,
|
||||
clientY: 80
|
||||
}],
|
||||
value: [
|
||||
{
|
||||
clientX: 300,
|
||||
clientY: 80
|
||||
}
|
||||
],
|
||||
writable: true
|
||||
})
|
||||
document.dispatchEvent(event)
|
||||
document.dispatchEvent(new MouseEvent('touchend'))
|
||||
await nextTick()
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal('50%')
|
||||
expect(wrapper.findAll('.splitpanes-pane')[0].element.style.width).to.equal(
|
||||
'50%'
|
||||
)
|
||||
wrapper.unmount()
|
||||
root.remove()
|
||||
delete window.ontouchstart
|
||||
|
||||
@@ -38,7 +38,11 @@ describe('splitter.js', () => {
|
||||
|
||||
document.body.appendChild(container)
|
||||
|
||||
const dragPercentage = splitter.getCurrentDragPercentage(event, container, isHorisontal)
|
||||
const dragPercentage = splitter.getCurrentDragPercentage(
|
||||
event,
|
||||
container,
|
||||
isHorisontal
|
||||
)
|
||||
expect(dragPercentage).to.equal(50)
|
||||
})
|
||||
|
||||
@@ -53,7 +57,11 @@ describe('splitter.js', () => {
|
||||
|
||||
document.body.appendChild(container)
|
||||
|
||||
const dragPercentage = splitter.getCurrentDragPercentage(event, container, isHorisontal)
|
||||
const dragPercentage = splitter.getCurrentDragPercentage(
|
||||
event,
|
||||
container,
|
||||
isHorisontal
|
||||
)
|
||||
expect(dragPercentage).to.equal(25)
|
||||
})
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('Pager.vue', () => {
|
||||
const wrapper = mount(Pager, {
|
||||
props: {
|
||||
pageCount: 5,
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -97,7 +97,8 @@ describe('chartHelper.js', () => {
|
||||
expect(doc.children[0].src).to.includes('plotly-latest.js')
|
||||
expect(doc.children[1].id).to.have.lengthOf(21)
|
||||
expect(doc.children[2].innerHTML).to.includes(doc.children[1].id)
|
||||
expect(doc.children[2].innerHTML)
|
||||
.to.includes('Plotly.newPlot(el, "plotly data", "plotly layout"')
|
||||
expect(doc.children[2].innerHTML).to.includes(
|
||||
'Plotly.newPlot(el, "plotly data", "plotly layout"'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -62,7 +62,9 @@ describe('_sql.js', () => {
|
||||
const data = tempDb.export()
|
||||
const sql = await Sql.build()
|
||||
sql.open(data)
|
||||
expect(() => { sql.exec() }).to.throw('exec: Missing query string')
|
||||
expect(() => {
|
||||
sql.exec()
|
||||
}).to.throw('exec: Missing query string')
|
||||
})
|
||||
|
||||
it('imports', async () => {
|
||||
|
||||
@@ -19,8 +19,9 @@ describe('_statements.js', () => {
|
||||
|
||||
it('getInsertStmt', () => {
|
||||
const columns = ['id', 'name']
|
||||
expect(stmts.getInsertStmt('foo', columns))
|
||||
.to.equal('INSERT INTO "foo" ("id", "name") VALUES (?, ?);')
|
||||
expect(stmts.getInsertStmt('foo', columns)).to.equal(
|
||||
'INSERT INTO "foo" ("id", "name") VALUES (?, ?);'
|
||||
)
|
||||
})
|
||||
|
||||
it('getCreateStatement', () => {
|
||||
|
||||
@@ -71,10 +71,12 @@ describe('database.js', () => {
|
||||
type: 'INTEGER'
|
||||
})
|
||||
|
||||
expect(schema[1].columns).to.eql([{
|
||||
name: 'amount',
|
||||
type: 'INTEGER'
|
||||
}])
|
||||
expect(schema[1].columns).to.eql([
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'INTEGER'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('creates empty db with name database', async () => {
|
||||
@@ -114,7 +116,9 @@ describe('database.js', () => {
|
||||
buffer.name = 'foo.sqlite'
|
||||
|
||||
await db.loadDb(buffer)
|
||||
const result = await db.execute('SELECT * from test limit 1; SELECT * from test;')
|
||||
const result = await db.execute(
|
||||
'SELECT * from test limit 1; SELECT * from test;'
|
||||
)
|
||||
expect(result.values).to.eql({
|
||||
id: [1, 2],
|
||||
name: ['Harry Potter', 'Draco Malfoy'],
|
||||
@@ -141,7 +145,9 @@ describe('database.js', () => {
|
||||
const buffer = new Blob([data])
|
||||
buffer.name = 'foo.sqlite'
|
||||
await db.loadDb(buffer)
|
||||
await expect(db.execute('SELECT * from foo')).to.be.rejectedWith(/^no such table: foo$/)
|
||||
await expect(db.execute('SELECT * from foo')).to.be.rejectedWith(
|
||||
/^no such table: foo$/
|
||||
)
|
||||
})
|
||||
|
||||
it('adds table from csv', async () => {
|
||||
@@ -186,37 +192,44 @@ describe('database.js', () => {
|
||||
}
|
||||
const progressHandler = sinon.stub()
|
||||
const progressCounterId = db.createProgressCounter(progressHandler)
|
||||
await expect(db.addTableFromCsv('foo', data, progressCounterId)).to.be.rejected
|
||||
await expect(db.addTableFromCsv('foo', data, progressCounterId)).to.be
|
||||
.rejected
|
||||
})
|
||||
|
||||
it('progressCounters', () => {
|
||||
const firstHandler = sinon.stub()
|
||||
const firstId = db.createProgressCounter(firstHandler)
|
||||
db.worker.dispatchEvent(new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 50,
|
||||
id: firstId
|
||||
}
|
||||
}))
|
||||
db.worker.dispatchEvent(
|
||||
new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 50,
|
||||
id: firstId
|
||||
}
|
||||
})
|
||||
)
|
||||
expect(firstHandler.calledOnceWith(50)).to.equal(true)
|
||||
|
||||
const secondHandler = sinon.stub()
|
||||
const secondId = db.createProgressCounter(secondHandler)
|
||||
db.worker.dispatchEvent(new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 70,
|
||||
id: secondId
|
||||
}
|
||||
}))
|
||||
db.worker.dispatchEvent(
|
||||
new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 70,
|
||||
id: secondId
|
||||
}
|
||||
})
|
||||
)
|
||||
expect(firstId).to.not.equals(secondId)
|
||||
expect(secondHandler.calledOnceWith(70)).to.equal(true)
|
||||
|
||||
db.worker.dispatchEvent(new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 80,
|
||||
id: firstId
|
||||
}
|
||||
}))
|
||||
db.worker.dispatchEvent(
|
||||
new MessageEvent('message', {
|
||||
data: {
|
||||
progress: 80,
|
||||
id: firstId
|
||||
}
|
||||
})
|
||||
)
|
||||
expect(firstHandler.calledTwice).to.equal(true)
|
||||
expect(firstHandler.secondCall.calledWith(80)).to.equal(true)
|
||||
|
||||
@@ -268,12 +281,17 @@ describe('database.js', () => {
|
||||
|
||||
it('validateTableName', async () => {
|
||||
await db.execute('CREATE TABLE foo(id)')
|
||||
await expect(db.validateTableName('foo')).to.be.rejectedWith('table "foo" already exists')
|
||||
await expect(db.validateTableName('1foo'))
|
||||
.to.be.rejectedWith("Table name can't start with a digit")
|
||||
await expect(db.validateTableName('foo(05.08.2020)'))
|
||||
.to.be.rejectedWith('Table name can contain only letters, digits and underscores')
|
||||
await expect(db.validateTableName('sqlite_foo'))
|
||||
.to.be.rejectedWith("Table name can't start with sqlite_")
|
||||
await expect(db.validateTableName('foo')).to.be.rejectedWith(
|
||||
'table "foo" already exists'
|
||||
)
|
||||
await expect(db.validateTableName('1foo')).to.be.rejectedWith(
|
||||
"Table name can't start with a digit"
|
||||
)
|
||||
await expect(db.validateTableName('foo(05.08.2020)')).to.be.rejectedWith(
|
||||
'Table name can contain only letters, digits and underscores'
|
||||
)
|
||||
await expect(db.validateTableName('sqlite_foo')).to.be.rejectedWith(
|
||||
"Table name can't start with sqlite_"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -80,7 +80,6 @@ describe('SQLite extensions', function () {
|
||||
'sqrt(square(16))': [16],
|
||||
'ceil(-1.95) + ceil(1.95)': [1],
|
||||
'floor(-1.95) + floor(1.95)': [-1]
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
@@ -452,7 +451,15 @@ describe('SQLite extensions', function () {
|
||||
FROM dataset;
|
||||
`)
|
||||
expect(actual.values).to.eql({
|
||||
xx: [1], xy: [0], xz: [1], yx: [0], yy: [1], yz: [1], zx: [1], zy: [1], zz: [1]
|
||||
xx: [1],
|
||||
xy: [0],
|
||||
xz: [1],
|
||||
yx: [0],
|
||||
yy: [1],
|
||||
yz: [1],
|
||||
zx: [1],
|
||||
zy: [1],
|
||||
zz: [1]
|
||||
})
|
||||
})
|
||||
|
||||
@@ -475,7 +482,10 @@ describe('SQLite extensions', function () {
|
||||
|
||||
SELECT lua_inline(1), lua_full(1) - 1 < 0.000001;
|
||||
`)
|
||||
expect(actual.values).to.eql({ 'lua_inline(1)': [2], 'lua_full(1) - 1 < 0.000001': [1] })
|
||||
expect(actual.values).to.eql({
|
||||
'lua_inline(1)': [2],
|
||||
'lua_full(1) - 1 < 0.000001': [1]
|
||||
})
|
||||
})
|
||||
|
||||
it('supports aggregate Lua functions', async function () {
|
||||
@@ -534,6 +544,9 @@ describe('SQLite extensions', function () {
|
||||
|
||||
SELECT * FROM lua_match('%w+', 'hello world from Lua');
|
||||
`)
|
||||
expect(actual.values).to.eql({ idx: [1, 2, 3, 4], elm: ['hello', 'world', 'from', 'Lua'] })
|
||||
expect(actual.values).to.eql({
|
||||
idx: [1, 2, 3, 4],
|
||||
elm: ['hello', 'world', 'from', 'Lua']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -19,20 +19,23 @@ describe('storedInquiries.js', () => {
|
||||
})
|
||||
|
||||
it('getStoredInquiries migrate and returns inquiries of v1', () => {
|
||||
localStorage.setItem('myQueries', JSON.stringify([
|
||||
{
|
||||
id: '123',
|
||||
name: 'foo',
|
||||
query: 'SELECT * FROM foo',
|
||||
chart: { here_are: 'foo chart settings' }
|
||||
},
|
||||
{
|
||||
id: '456',
|
||||
name: 'bar',
|
||||
query: 'SELECT * FROM bar',
|
||||
chart: { here_are: 'bar chart settings' }
|
||||
}
|
||||
]))
|
||||
localStorage.setItem(
|
||||
'myQueries',
|
||||
JSON.stringify([
|
||||
{
|
||||
id: '123',
|
||||
name: 'foo',
|
||||
query: 'SELECT * FROM foo',
|
||||
chart: { here_are: 'foo chart settings' }
|
||||
},
|
||||
{
|
||||
id: '456',
|
||||
name: 'bar',
|
||||
query: 'SELECT * FROM bar',
|
||||
chart: { here_are: 'bar chart settings' }
|
||||
}
|
||||
])
|
||||
)
|
||||
const inquiries = storedInquiries.getStoredInquiries()
|
||||
expect(inquiries).to.eql([
|
||||
{
|
||||
@@ -53,10 +56,7 @@ describe('storedInquiries.js', () => {
|
||||
})
|
||||
|
||||
it('updateStorage and getStoredInquiries', () => {
|
||||
const data = [
|
||||
{ id: 1 },
|
||||
{ id: 2 }
|
||||
]
|
||||
const data = [{ id: 1 }, { id: 2 }]
|
||||
storedInquiries.updateStorage(data)
|
||||
const inquiries = storedInquiries.getStoredInquiries()
|
||||
expect(inquiries).to.eql(data)
|
||||
@@ -77,7 +77,9 @@ describe('storedInquiries.js', () => {
|
||||
|
||||
const copy = storedInquiries.duplicateInquiry(base)
|
||||
expect(copy).to.have.property('id').which.not.equal(base.id)
|
||||
expect(copy).to.have.property('name').which.equal(base.name + ' Copy')
|
||||
expect(copy)
|
||||
.to.have.property('name')
|
||||
.which.equal(base.name + ' Copy')
|
||||
expect(copy).to.have.property('query').which.equal(base.query)
|
||||
expect(copy).to.have.property('viewType').which.equal(base.viewType)
|
||||
expect(copy).to.have.property('viewOptions').which.eql(base.viewOptions)
|
||||
@@ -197,14 +199,16 @@ describe('storedInquiries.js', () => {
|
||||
`
|
||||
|
||||
const inquiry = storedInquiries.deserialiseInquiries(str)
|
||||
expect(inquiry).to.eql([{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}])
|
||||
expect(inquiry).to.eql([
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('deserialiseInquiries generates new id to avoid duplication', () => {
|
||||
@@ -256,14 +260,16 @@ describe('storedInquiries.js', () => {
|
||||
sinon.stub(fu, 'importFile').returns(Promise.resolve(str))
|
||||
const inquiries = await storedInquiries.importInquiries()
|
||||
|
||||
expect(inquiries).to.eql([{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}])
|
||||
expect(inquiries).to.eql([
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('importInquiries', async () => {
|
||||
@@ -281,14 +287,16 @@ describe('storedInquiries.js', () => {
|
||||
sinon.stub(fu, 'importFile').returns(Promise.resolve(str))
|
||||
const inquiries = await storedInquiries.importInquiries()
|
||||
|
||||
expect(inquiries).to.eql([{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}])
|
||||
expect(inquiries).to.eql([
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('readPredefinedInquiries old', async () => {
|
||||
@@ -312,7 +320,8 @@ describe('storedInquiries.js', () => {
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}])
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('readPredefinedInquiries', async () => {
|
||||
@@ -340,6 +349,7 @@ describe('storedInquiries.js', () => {
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T14:17:49.524Z'
|
||||
}])
|
||||
}
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -75,9 +75,11 @@ describe('tab.js', () => {
|
||||
currentTabId: 1,
|
||||
dbName: 'fooDb',
|
||||
db: {
|
||||
execute: sinon.stub().returns(new Promise(resolve => {
|
||||
resolveQuering = resolve
|
||||
})),
|
||||
execute: sinon.stub().returns(
|
||||
new Promise(resolve => {
|
||||
resolveQuering = resolve
|
||||
})
|
||||
),
|
||||
refreshSchema: sinon.stub().resolves()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ describe('fileIo.js', () => {
|
||||
|
||||
expect(document.createElement.calledOnceWith('a')).to.equal(true)
|
||||
|
||||
expect(window.Blob.calledOnceWith(['foo'], { type: 'octet/stream' })).to.equal(true)
|
||||
expect(
|
||||
window.Blob.calledOnceWith(['foo'], { type: 'octet/stream' })
|
||||
).to.equal(true)
|
||||
const blob = window.Blob.returnValues[0]
|
||||
expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true)
|
||||
|
||||
@@ -49,7 +51,9 @@ describe('fileIo.js', () => {
|
||||
|
||||
expect(document.createElement.calledOnceWith('a')).to.equal(true)
|
||||
|
||||
expect(window.Blob.calledOnceWith(['foo'], { type: 'text/html' })).to.equal(true)
|
||||
expect(window.Blob.calledOnceWith(['foo'], { type: 'text/html' })).to.equal(
|
||||
true
|
||||
)
|
||||
const blob = window.Blob.returnValues[0]
|
||||
expect(URL.createObjectURL.calledOnceWith(blob)).to.equal(true)
|
||||
|
||||
@@ -74,7 +78,9 @@ describe('fileIo.js', () => {
|
||||
|
||||
sinon.stub(document, 'createElement').returns(spyInput)
|
||||
|
||||
setTimeout(() => { spyInput.dispatchEvent(new Event('change')) })
|
||||
setTimeout(() => {
|
||||
spyInput.dispatchEvent(new Event('change'))
|
||||
})
|
||||
|
||||
const data = await fIo.importFile()
|
||||
expect(data).to.equal('foo')
|
||||
@@ -108,7 +114,9 @@ describe('fileIo.js', () => {
|
||||
sinon.stub(window, 'FileReader').returns(r)
|
||||
|
||||
const blob = new Blob(['foo'])
|
||||
await expect(fIo.readAsArrayBuffer(blob)).to.be.rejectedWith('Problem parsing input file.')
|
||||
await expect(fIo.readAsArrayBuffer(blob)).to.be.rejectedWith(
|
||||
'Problem parsing input file.'
|
||||
)
|
||||
})
|
||||
|
||||
it('isJSON', () => {
|
||||
|
||||
@@ -2,13 +2,8 @@ import { expect } from 'chai'
|
||||
import actions from '@/store/actions'
|
||||
import sinon from 'sinon'
|
||||
|
||||
const {
|
||||
addTab,
|
||||
addInquiry,
|
||||
deleteInquiries,
|
||||
renameInquiry,
|
||||
saveInquiry
|
||||
} = actions
|
||||
const { addTab, addInquiry, deleteInquiries, renameInquiry, saveInquiry } =
|
||||
actions
|
||||
|
||||
describe('actions', () => {
|
||||
it('addTab adds new blank tab', async () => {
|
||||
@@ -117,22 +112,30 @@ describe('actions', () => {
|
||||
{ id: 2, name: 'bar' },
|
||||
{ id: 3, name: 'baz' }
|
||||
],
|
||||
tabs: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }]
|
||||
tabs: [
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'bar' }
|
||||
]
|
||||
}
|
||||
const commit = sinon.spy()
|
||||
|
||||
await renameInquiry({ state, commit }, { inquiryId: 2, newName: 'new name' })
|
||||
await renameInquiry(
|
||||
{ state, commit },
|
||||
{ inquiryId: 2, newName: 'new name' }
|
||||
)
|
||||
expect(state.inquiries).to.eql([
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'new name' },
|
||||
{ id: 3, name: 'baz' }
|
||||
])
|
||||
expect(commit.calledWith('updateTab', {
|
||||
tab: { id: 2, name: 'bar' },
|
||||
newValues: {
|
||||
name: 'new name'
|
||||
}
|
||||
})).to.equal(true)
|
||||
expect(
|
||||
commit.calledWith('updateTab', {
|
||||
tab: { id: 2, name: 'bar' },
|
||||
newValues: {
|
||||
name: 'new name'
|
||||
}
|
||||
})
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('saveInquiry adds new inquiry in the storage', async () => {
|
||||
@@ -146,7 +149,7 @@ describe('actions', () => {
|
||||
viewOptions: [],
|
||||
name: null,
|
||||
dataView: {
|
||||
getOptionsForSave () {
|
||||
getOptionsForSave() {
|
||||
return ['chart']
|
||||
}
|
||||
}
|
||||
@@ -156,10 +159,13 @@ describe('actions', () => {
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
const value = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
const value = await saveInquiry(
|
||||
{ state },
|
||||
{
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
}
|
||||
)
|
||||
expect(value.id).to.equal(tab.id)
|
||||
expect(value.name).to.equal('foo')
|
||||
expect(value.query).to.equal(tab.query)
|
||||
@@ -176,7 +182,7 @@ describe('actions', () => {
|
||||
viewOptions: [],
|
||||
name: null,
|
||||
dataView: {
|
||||
getOptionsForSave () {
|
||||
getOptionsForSave() {
|
||||
return ['chart']
|
||||
}
|
||||
}
|
||||
@@ -187,10 +193,13 @@ describe('actions', () => {
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
const first = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
const first = await saveInquiry(
|
||||
{ state },
|
||||
{
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
}
|
||||
)
|
||||
|
||||
tab.name = 'foo'
|
||||
tab.query = 'select * from foo'
|
||||
@@ -202,7 +211,9 @@ describe('actions', () => {
|
||||
expect(second.name).to.equal(first.name)
|
||||
expect(second.query).to.equal(tab.query)
|
||||
expect(second.viewOptions).to.eql(['chart'])
|
||||
expect(new Date(second.createdAt).getTime()).to.equal(first.createdAt.getTime())
|
||||
expect(new Date(second.createdAt).getTime()).to.equal(
|
||||
first.createdAt.getTime()
|
||||
)
|
||||
})
|
||||
|
||||
it("save adds a new inquiry with new id if it's based on predefined inquiry", async () => {
|
||||
@@ -215,7 +226,7 @@ describe('actions', () => {
|
||||
viewOptions: [],
|
||||
name: 'foo predefined',
|
||||
dataView: {
|
||||
getOptionsForSave () {
|
||||
getOptionsForSave() {
|
||||
return ['chart']
|
||||
}
|
||||
},
|
||||
@@ -227,10 +238,13 @@ describe('actions', () => {
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
await saveInquiry(
|
||||
{ state },
|
||||
{
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
}
|
||||
)
|
||||
|
||||
const inquiries = state.inquiries
|
||||
expect(inquiries).has.lengthOf(1)
|
||||
|
||||
@@ -319,22 +319,24 @@ describe('mutations', () => {
|
||||
})
|
||||
|
||||
it('updatePredefinedInquiries - array', () => {
|
||||
const inquiries = [{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: {},
|
||||
createdAt: '2020-11-07T20:57:04.492Z'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: 'SELECT * FROM bar',
|
||||
viewType: 'chart',
|
||||
viewOptions: {},
|
||||
createdAt: '2020-11-07T20:57:04.492Z'
|
||||
}]
|
||||
const inquiries = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: {},
|
||||
createdAt: '2020-11-07T20:57:04.492Z'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: 'SELECT * FROM bar',
|
||||
viewType: 'chart',
|
||||
viewOptions: {},
|
||||
createdAt: '2020-11-07T20:57:04.492Z'
|
||||
}
|
||||
]
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: []
|
||||
|
||||
@@ -24,17 +24,20 @@ describe('tooltipMixin.js', () => {
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: top-right', async () => {
|
||||
const component = {
|
||||
template: '<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
template:
|
||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
|
||||
// by default top-right
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}))
|
||||
await wrapper.vm.showTooltip(
|
||||
new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
})
|
||||
)
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
top: '8px',
|
||||
@@ -45,15 +48,19 @@ describe('tooltipMixin.js', () => {
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: top-left', async () => {
|
||||
const component = {
|
||||
template: '<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
template:
|
||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 212,
|
||||
clientY: 20
|
||||
}), 'top-left')
|
||||
await wrapper.vm.showTooltip(
|
||||
new MouseEvent('mouseenter', {
|
||||
clientX: 212,
|
||||
clientY: 20
|
||||
}),
|
||||
'top-left'
|
||||
)
|
||||
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
@@ -66,15 +73,19 @@ describe('tooltipMixin.js', () => {
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: bottom-right', async () => {
|
||||
const component = {
|
||||
template: '<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
template:
|
||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}), 'bottom-right')
|
||||
await wrapper.vm.showTooltip(
|
||||
new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}),
|
||||
'bottom-right'
|
||||
)
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
top: '32px',
|
||||
@@ -85,15 +96,19 @@ describe('tooltipMixin.js', () => {
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: bottom-left', async () => {
|
||||
const component = {
|
||||
template: '<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
template:
|
||||
'<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 212,
|
||||
clientY: 20
|
||||
}), 'bottom-left')
|
||||
await wrapper.vm.showTooltip(
|
||||
new MouseEvent('mouseenter', {
|
||||
clientX: 212,
|
||||
clientY: 20
|
||||
}),
|
||||
'bottom-left'
|
||||
)
|
||||
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
@@ -109,10 +124,12 @@ describe('tooltipMixin.js', () => {
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}))
|
||||
await wrapper.vm.showTooltip(
|
||||
new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
})
|
||||
)
|
||||
await wrapper.vm.hideTooltip()
|
||||
expect(wrapper.find('div').isVisible()).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -48,7 +48,10 @@ describe('LoadView.vue', () => {
|
||||
const inquiriesRes = new Response()
|
||||
inquiriesRes.json = sinon.stub().resolves({
|
||||
version: 2,
|
||||
inquiries: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }]
|
||||
inquiries: [
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'bar' }
|
||||
]
|
||||
})
|
||||
readFile.onCall(1).returns(Promise.resolve(inquiriesRes))
|
||||
const db = {
|
||||
@@ -71,11 +74,14 @@ describe('LoadView.vue', () => {
|
||||
expect(fu.readFile.firstCall.args[0]).to.equal('https://my-url/test.db')
|
||||
|
||||
// Db is loaded
|
||||
expect(db.loadDb.firstCall.args[0]).to.equal(await dataRes.blob.returnValues[0])
|
||||
expect(db.loadDb.firstCall.args[0]).to.equal(
|
||||
await dataRes.blob.returnValues[0]
|
||||
)
|
||||
|
||||
// Inquiries file is read
|
||||
expect(fu.readFile.secondCall.args[0])
|
||||
.to.equal('https://my-url/test_inquiries.json')
|
||||
expect(fu.readFile.secondCall.args[0]).to.equal(
|
||||
'https://my-url/test_inquiries.json'
|
||||
)
|
||||
|
||||
// Tab for inquiry is created
|
||||
expect(actions.addTab.calledOnce).to.equal(true)
|
||||
@@ -95,7 +101,7 @@ describe('LoadView.vue', () => {
|
||||
expect($router.push.called).to.equal(true)
|
||||
})
|
||||
|
||||
it('Doesn\'t redirect and show the button if there is an error', async () => {
|
||||
it("Doesn't redirect and show the button if there is an error", async () => {
|
||||
const state = {
|
||||
tabs: []
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import actions from '@/store/actions'
|
||||
import fu from '@/lib/utils/fileIo'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
|
||||
describe('Inquiries.vue', () => {
|
||||
let clock
|
||||
|
||||
@@ -80,7 +79,7 @@ describe('Inquiries.vue', () => {
|
||||
const store = createStore({ state, mutations, actions })
|
||||
const wrapper = shallowMount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: { plugins: [store] }
|
||||
global: { plugins: [store] }
|
||||
})
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
@@ -187,13 +186,15 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
const store = createStore({ state, mutations, actions })
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: { plugins: [store] }
|
||||
attachTo: document.body,
|
||||
global: { plugins: [store] }
|
||||
})
|
||||
await wrapper.find('#toolbar-search input').setValue('baz')
|
||||
await nextTick()
|
||||
|
||||
expect(wrapper.find('#inquiries-not-found').text()).to.equal('No inquiries found')
|
||||
expect(wrapper.find('#inquiries-not-found').text()).to.equal(
|
||||
'No inquiries found'
|
||||
)
|
||||
expect(wrapper.find('#start-guide').exists()).to.equal(false)
|
||||
expect(wrapper.find('tbody').isVisible()).to.equal(false)
|
||||
wrapper.unmount()
|
||||
@@ -242,7 +243,9 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
it('Exports one inquiry', async () => {
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiry')
|
||||
sinon
|
||||
.stub(storedInquiries, 'serialiseInquiries')
|
||||
.returns('I am a serialized inquiry')
|
||||
sinon.stub(fu, 'exportToFile')
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
@@ -262,8 +265,13 @@ describe('Inquiries.vue', () => {
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
await wrapper.findComponent({ name: 'ExportIcon' }).find('svg').trigger('click')
|
||||
expect(fu.exportToFile.calledOnceWith('I am a serialized inquiry', 'foo.json')).to.equals(true)
|
||||
await wrapper
|
||||
.findComponent({ name: 'ExportIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
expect(
|
||||
fu.exportToFile.calledOnceWith('I am a serialized inquiry', 'foo.json')
|
||||
).to.equals(true)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -296,9 +304,14 @@ describe('Inquiries.vue', () => {
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
await wrapper.findComponent({ name: 'CopyIcon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'CopyIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
|
||||
expect(storedInquiries.duplicateInquiry.calledOnceWith(inquiryInStorage)).to.equals(true)
|
||||
expect(
|
||||
storedInquiries.duplicateInquiry.calledOnceWith(inquiryInStorage)
|
||||
).to.equals(true)
|
||||
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(2)
|
||||
@@ -308,44 +321,48 @@ describe('Inquiries.vue', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('The copy of the inquiry is not selected if all inquiries were selected before duplication',
|
||||
async () => {
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||
const inquiryInStorage = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T19:57:56.299Z'
|
||||
}
|
||||
const newInquiry = {
|
||||
id: 2,
|
||||
name: 'foo copy',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-12-03T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [inquiryInStorage]
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
it('The copy of the inquiry is not selected if all inquiries were selected before duplication', async () => {
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||
const inquiryInStorage = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T19:57:56.299Z'
|
||||
}
|
||||
const newInquiry = {
|
||||
id: 2,
|
||||
name: 'foo copy',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-12-03T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [inquiryInStorage]
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||
.trigger('click')
|
||||
await wrapper.findComponent({ name: 'CopyIcon' }).find('svg').trigger('click')
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
await wrapper
|
||||
.findComponent({ ref: 'mainCheckBox' })
|
||||
.find('.checkbox-container')
|
||||
.trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'CopyIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
|
||||
const checkboxes = wrapper.findAllComponents('[data-test="rowCheckBox"]')
|
||||
expect(checkboxes[0].vm.checked).to.equals(true)
|
||||
expect(checkboxes[1].vm.checked).to.equals(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
const checkboxes = wrapper.findAllComponents('[data-test="rowCheckBox"]')
|
||||
expect(checkboxes[0].vm.checked).to.equals(true)
|
||||
expect(checkboxes[1].vm.checked).to.equals(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('Opens an inquiry', async () => {
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||
@@ -408,7 +425,9 @@ describe('Inquiries.vue', () => {
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
expect(wrapper.findComponent({ name: 'RenameIcon' }).exists()).to.equals(false)
|
||||
expect(wrapper.findComponent({ name: 'RenameIcon' }).exists()).to.equals(
|
||||
false
|
||||
)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -432,7 +451,7 @@ describe('Inquiries.vue', () => {
|
||||
const store = createStore({ state, mutations, actions })
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: { teleport: true, transition: false }
|
||||
}
|
||||
@@ -441,12 +460,16 @@ describe('Inquiries.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
// click Rename icon in the grid
|
||||
await wrapper.findComponent({ name: 'RenameIcon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'RenameIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
|
||||
// check that rename dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Rename inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Rename inquiry'
|
||||
)
|
||||
|
||||
// check that input is filled by the current inquiry name
|
||||
expect(wrapper.find('.dialog-body input').element.value).to.equals('foo')
|
||||
@@ -465,14 +488,16 @@ describe('Inquiries.vue', () => {
|
||||
expect(wrapper.find('tbody tr td').text()).to.equals('bar')
|
||||
|
||||
// check that storage is updated
|
||||
expect(state.inquiries).to.eql([{
|
||||
id: 1,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T19:57:56.299Z'
|
||||
}])
|
||||
expect(state.inquiries).to.eql([
|
||||
{
|
||||
id: 1,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-11-03T19:57:56.299Z'
|
||||
}
|
||||
])
|
||||
|
||||
// check that coresponding tab also changed the name
|
||||
expect(state.tabs[0].name).to.equals('bar')
|
||||
@@ -513,7 +538,10 @@ describe('Inquiries.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
// click Rename icon in the grid
|
||||
await wrapper.findComponent({ name: 'RenameIcon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'RenameIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
|
||||
// change the name
|
||||
await wrapper.find('.dialog-body input').setValue('')
|
||||
@@ -524,8 +552,9 @@ describe('Inquiries.vue', () => {
|
||||
.find(button => button.text() === 'Rename')
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.find('.dialog-body .text-field-error').text())
|
||||
.to.equals("Inquiry name can't be empty")
|
||||
expect(wrapper.find('.dialog-body .text-field-error').text()).to.equals(
|
||||
"Inquiry name can't be empty"
|
||||
)
|
||||
// check that rename dialog is still open
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
@@ -604,19 +633,23 @@ describe('Inquiries.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
// click on master checkbox
|
||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||
await wrapper
|
||||
.findComponent({ ref: 'mainCheckBox' })
|
||||
.find('.checkbox-container')
|
||||
.trigger('click')
|
||||
|
||||
// click Import
|
||||
await wrapper.find('#toolbar-btns-import').trigger('click')
|
||||
|
||||
const checkboxes = wrapper.findAllComponents('[data-test="rowCheckBox"]')
|
||||
expect(wrapper.findComponent({ ref: 'mainCheckBox' }).vm.checked).to.equals(false)
|
||||
expect(wrapper.findComponent({ ref: 'mainCheckBox' }).vm.checked).to.equals(
|
||||
false
|
||||
)
|
||||
expect(checkboxes[0].vm.checked).to.equals(true)
|
||||
expect(checkboxes[1].vm.checked).to.equals(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
|
||||
it('Deletion is not available for predefined inquiries', async () => {
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([
|
||||
{
|
||||
@@ -638,7 +671,9 @@ describe('Inquiries.vue', () => {
|
||||
const wrapper = mount(Inquiries, { global: { plugins: [store] } })
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
expect(wrapper.findComponent({ name: 'DeleteIcon' }).exists()).to.equals(false)
|
||||
expect(wrapper.findComponent({ name: 'DeleteIcon' }).exists()).to.equals(
|
||||
false
|
||||
)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -671,20 +706,24 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: { teleport: true, transition: false }
|
||||
}
|
||||
})
|
||||
})
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
// click Delete icon in the first row of the grid
|
||||
await wrapper.findComponent({ name: 'DeleteIcon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'DeleteIcon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
|
||||
// check that delete dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Delete inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Delete inquiry'
|
||||
)
|
||||
|
||||
// check the message in the dialog
|
||||
expect(wrapper.find('.dialog-body').text()).to.contains('"foo"?')
|
||||
@@ -777,7 +816,9 @@ describe('Inquiries.vue', () => {
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([predefinedInquiry])
|
||||
sinon
|
||||
.stub(storedInquiries, 'readPredefinedInquiries')
|
||||
.resolves([predefinedInquiry])
|
||||
const inquiryInStore = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -787,19 +828,24 @@ describe('Inquiries.vue', () => {
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
|
||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
||||
sinon
|
||||
.stub(storedInquiries, 'serialiseInquiries')
|
||||
.returns('I am a serialized inquiries')
|
||||
sinon.stub(fu, 'exportToFile')
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [inquiryInStore, {
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}]
|
||||
inquiries: [
|
||||
inquiryInStore,
|
||||
{
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
]
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
|
||||
@@ -815,12 +861,17 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
await wrapper.find('#toolbar-btns-export').trigger('click')
|
||||
|
||||
expect(storedInquiries.serialiseInquiries.calledOnceWith(
|
||||
sinon.match([predefinedInquiry, inquiryInStore])
|
||||
)).to.equals(true)
|
||||
expect(
|
||||
storedInquiries.serialiseInquiries.calledOnceWith(
|
||||
sinon.match([predefinedInquiry, inquiryInStore])
|
||||
)
|
||||
).to.equals(true)
|
||||
|
||||
expect(
|
||||
fu.exportToFile.calledOnceWith('I am a serialized inquiries', 'My sqliteviz inquiries.json')
|
||||
fu.exportToFile.calledOnceWith(
|
||||
'I am a serialized inquiries',
|
||||
'My sqliteviz inquiries.json'
|
||||
)
|
||||
).to.equals(true)
|
||||
wrapper.unmount()
|
||||
})
|
||||
@@ -834,7 +885,9 @@ describe('Inquiries.vue', () => {
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([predefinedInquiry])
|
||||
sinon
|
||||
.stub(storedInquiries, 'readPredefinedInquiries')
|
||||
.resolves([predefinedInquiry])
|
||||
const inquiryInStore = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -844,7 +897,9 @@ describe('Inquiries.vue', () => {
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
|
||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
||||
sinon
|
||||
.stub(storedInquiries, 'serialiseInquiries')
|
||||
.returns('I am a serialized inquiries')
|
||||
sinon.stub(fu, 'exportToFile')
|
||||
|
||||
const state = {
|
||||
@@ -857,17 +912,24 @@ describe('Inquiries.vue', () => {
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
|
||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||
await wrapper
|
||||
.findComponent({ ref: 'mainCheckBox' })
|
||||
.find('.checkbox-container')
|
||||
.trigger('click')
|
||||
|
||||
await wrapper.find('#toolbar-btns-export').trigger('click')
|
||||
|
||||
expect(storedInquiries.serialiseInquiries.calledOnceWith(
|
||||
sinon.match([predefinedInquiry, inquiryInStore])
|
||||
)).to.equals(true)
|
||||
expect(
|
||||
storedInquiries.serialiseInquiries.calledOnceWith(
|
||||
sinon.match([predefinedInquiry, inquiryInStore])
|
||||
)
|
||||
).to.equals(true)
|
||||
|
||||
expect(
|
||||
fu.exportToFile.calledOnceWith('I am a serialized inquiries', 'My sqliteviz inquiries.json')
|
||||
fu.exportToFile.calledOnceWith(
|
||||
'I am a serialized inquiries',
|
||||
'My sqliteviz inquiries.json'
|
||||
)
|
||||
).to.equals(true)
|
||||
wrapper.unmount()
|
||||
})
|
||||
@@ -881,7 +943,9 @@ describe('Inquiries.vue', () => {
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([predefinedInquiry])
|
||||
sinon
|
||||
.stub(storedInquiries, 'readPredefinedInquiries')
|
||||
.resolves([predefinedInquiry])
|
||||
const foo = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -918,10 +982,10 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: { teleport: true, transition: false }
|
||||
}
|
||||
}
|
||||
})
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
@@ -938,8 +1002,9 @@ describe('Inquiries.vue', () => {
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
|
||||
// check the message in the dialog
|
||||
expect(wrapper.find('.dialog-body').text())
|
||||
.to.contains('Are you sure you want to delete 2 inquiries?')
|
||||
expect(wrapper.find('.dialog-body').text()).to.contains(
|
||||
'Are you sure you want to delete 2 inquiries?'
|
||||
)
|
||||
|
||||
// find Delete in the dialog and click
|
||||
await wrapper
|
||||
@@ -949,7 +1014,9 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
// check the rows in the grid
|
||||
expect(wrapper.findAll('tbody tr')).to.have.lengthOf(2)
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains('hello_world')
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains(
|
||||
'hello_world'
|
||||
)
|
||||
expect(wrapper.findAll('tbody tr')[1].find('td').text()).to.equals('baz')
|
||||
|
||||
// check that deleted inquiry was also deleted from tabs
|
||||
@@ -975,89 +1042,9 @@ describe('Inquiries.vue', () => {
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([predefinedInquiry])
|
||||
const foo = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
const bar = {
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'updateStorage')
|
||||
|
||||
const state = {
|
||||
tabs: [],
|
||||
predefinedInquiries: [],
|
||||
inquiries: [foo, bar]
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: { teleport: true, transition: false }
|
||||
}
|
||||
})
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
|
||||
// Select inquiries (select also predefined inquiries)
|
||||
await rows[0].find('.checkbox-container').trigger('click')
|
||||
await rows[1].find('.checkbox-container').trigger('click')
|
||||
|
||||
await wrapper.find('#toolbar-btns-delete').trigger('click')
|
||||
|
||||
// check that delete dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
|
||||
// check the message in the dialog
|
||||
expect(wrapper.find('.dialog-body').text())
|
||||
.to.contains('Are you sure you want to delete 1 inquiry?')
|
||||
|
||||
expect(wrapper.find('.dialog-body #note').isVisible()).to.equals(true)
|
||||
|
||||
// find Delete in the dialog and click
|
||||
await wrapper
|
||||
.findAll('.dialog-buttons-container button')
|
||||
.find(button => button.text() === 'Delete')
|
||||
.trigger('click')
|
||||
|
||||
// check the rows in the grid
|
||||
expect(wrapper.findAll('tbody tr')).to.have.lengthOf(2)
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains('hello_world')
|
||||
expect(wrapper.findAll('tbody tr')[1].find('td').text()).to.equals('bar')
|
||||
|
||||
// check that storage is updated
|
||||
expect(state.inquiries).to.eql([bar])
|
||||
|
||||
// check that delete dialog is closed
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('Deletes all inquiries ignoring predefined ones', async () => {
|
||||
const predefinedInquiry = {
|
||||
id: 0,
|
||||
name: 'hello_world',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([predefinedInquiry])
|
||||
sinon
|
||||
.stub(storedInquiries, 'readPredefinedInquiries')
|
||||
.resolves([predefinedInquiry])
|
||||
const foo = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -1093,7 +1080,96 @@ describe('Inquiries.vue', () => {
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
|
||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
|
||||
// Select inquiries (select also predefined inquiries)
|
||||
await rows[0].find('.checkbox-container').trigger('click')
|
||||
await rows[1].find('.checkbox-container').trigger('click')
|
||||
|
||||
await wrapper.find('#toolbar-btns-delete').trigger('click')
|
||||
|
||||
// check that delete dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
|
||||
// check the message in the dialog
|
||||
expect(wrapper.find('.dialog-body').text()).to.contains(
|
||||
'Are you sure you want to delete 1 inquiry?'
|
||||
)
|
||||
|
||||
expect(wrapper.find('.dialog-body #note').isVisible()).to.equals(true)
|
||||
|
||||
// find Delete in the dialog and click
|
||||
await wrapper
|
||||
.findAll('.dialog-buttons-container button')
|
||||
.find(button => button.text() === 'Delete')
|
||||
.trigger('click')
|
||||
|
||||
// check the rows in the grid
|
||||
expect(wrapper.findAll('tbody tr')).to.have.lengthOf(2)
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains(
|
||||
'hello_world'
|
||||
)
|
||||
expect(wrapper.findAll('tbody tr')[1].find('td').text()).to.equals('bar')
|
||||
|
||||
// check that storage is updated
|
||||
expect(state.inquiries).to.eql([bar])
|
||||
|
||||
// check that delete dialog is closed
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('Deletes all inquiries ignoring predefined ones', async () => {
|
||||
const predefinedInquiry = {
|
||||
id: 0,
|
||||
name: 'hello_world',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon
|
||||
.stub(storedInquiries, 'readPredefinedInquiries')
|
||||
.resolves([predefinedInquiry])
|
||||
const foo = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
const bar = {
|
||||
id: 2,
|
||||
name: 'bar',
|
||||
query: '',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
sinon.stub(storedInquiries, 'updateStorage')
|
||||
|
||||
const state = {
|
||||
tabs: [],
|
||||
predefinedInquiries: [],
|
||||
inquiries: [foo, bar]
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
|
||||
const wrapper = mount(Inquiries, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
plugins: [store],
|
||||
stubs: { teleport: true, transition: false }
|
||||
}
|
||||
})
|
||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||
await nextTick()
|
||||
|
||||
await wrapper
|
||||
.findComponent({ ref: 'mainCheckBox' })
|
||||
.find('.checkbox-container')
|
||||
.trigger('click')
|
||||
|
||||
await wrapper.find('#toolbar-btns-delete').trigger('click')
|
||||
@@ -1102,8 +1178,9 @@ describe('Inquiries.vue', () => {
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
|
||||
// check the message in the dialog
|
||||
expect(wrapper.find('.dialog-body').text())
|
||||
.to.contains('Are you sure you want to delete 2 inquiries?')
|
||||
expect(wrapper.find('.dialog-body').text()).to.contains(
|
||||
'Are you sure you want to delete 2 inquiries?'
|
||||
)
|
||||
|
||||
expect(wrapper.find('.dialog-body #note').isVisible()).to.equals(true)
|
||||
|
||||
@@ -1115,7 +1192,9 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
// check the rows in the grid
|
||||
expect(wrapper.findAll('tbody tr')).to.have.lengthOf(1)
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains('hello_world')
|
||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains(
|
||||
'hello_world'
|
||||
)
|
||||
|
||||
// check that storage is updated
|
||||
expect(state.inquiries).to.eql([])
|
||||
|
||||
@@ -150,7 +150,9 @@ describe('MainMenu.vue', () => {
|
||||
await wrapper.find('#create-btn').trigger('click')
|
||||
expect(actions.addTab.calledOnce).to.equal(true)
|
||||
await actions.addTab.returnValues[0]
|
||||
expect(mutations.setCurrentTabId.calledOnceWith(state, newInquiryId)).to.equal(true)
|
||||
expect(
|
||||
mutations.setCurrentTabId.calledOnceWith(state, newInquiryId)
|
||||
).to.equal(true)
|
||||
expect($router.push.calledOnce).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -187,106 +189,112 @@ describe('MainMenu.vue', () => {
|
||||
await wrapper.find('#create-btn').trigger('click')
|
||||
expect(actions.addTab.calledOnce).to.equal(true)
|
||||
await actions.addTab.returnValues[0]
|
||||
expect(mutations.setCurrentTabId.calledOnceWith(state, newInquiryId)).to.equal(true)
|
||||
expect(
|
||||
mutations.setCurrentTabId.calledOnceWith(state, newInquiryId)
|
||||
).to.equal(true)
|
||||
expect($router.push.calledOnce).to.equal(true)
|
||||
})
|
||||
|
||||
it('Ctrl R calls currentTab.execute if running is enabled and route.path is "/workspace"',
|
||||
async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
it('Ctrl R calls currentTab.execute if running is enabled and route.path is "/workspace"', async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
const $router = { push: sinon.stub() }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route, $router },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
const $router = { push: sinon.stub() }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route, $router },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
|
||||
const ctrlR = new KeyboardEvent('keydown', { key: 'r', ctrlKey: true })
|
||||
const metaR = new KeyboardEvent('keydown', { key: 'r', metaKey: true })
|
||||
// Running is enabled and route path is workspace
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is disabled and route path is workspace
|
||||
store.state.db = null
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is enabled and route path is not workspace
|
||||
state.db = {}
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
})
|
||||
|
||||
it('Ctrl Enter calls currentTab.execute if running is enabled and route.path is "/workspace"',
|
||||
async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
const ctrlR = new KeyboardEvent('keydown', { key: 'r', ctrlKey: true })
|
||||
const metaR = new KeyboardEvent('keydown', { key: 'r', metaKey: true })
|
||||
// Running is enabled and route path is workspace
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is disabled and route path is workspace
|
||||
store.state.db = null
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is enabled and route path is not workspace
|
||||
state.db = {}
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
document.dispatchEvent(ctrlR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaR)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
})
|
||||
|
||||
it('Ctrl Enter calls currentTab.execute if running is enabled and route.path is "/workspace"', async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
const $router = { push: sinon.stub() }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route, $router },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
const $router = { push: sinon.stub() }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route, $router },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
|
||||
const ctrlEnter = new KeyboardEvent('keydown', { key: 'Enter', ctrlKey: true })
|
||||
const metaEnter = new KeyboardEvent('keydown', { key: 'Enter', metaKey: true })
|
||||
// Running is enabled and route path is workspace
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is disabled and route path is workspace
|
||||
store.state.db = null
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is enabled and route path is not workspace
|
||||
store.state.db = {}
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
})
|
||||
|
||||
const ctrlEnter = new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
ctrlKey: true
|
||||
})
|
||||
const metaEnter = new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
metaKey: true
|
||||
})
|
||||
// Running is enabled and route path is workspace
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is disabled and route path is workspace
|
||||
store.state.db = null
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
|
||||
// Running is enabled and route path is not workspace
|
||||
store.state.db = {}
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
document.dispatchEvent(ctrlEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaEnter)
|
||||
expect(state.currentTab.execute.calledTwice).to.equal(true)
|
||||
})
|
||||
|
||||
it('Ctrl B calls createNewInquiry', async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
@@ -324,124 +332,130 @@ describe('MainMenu.vue', () => {
|
||||
expect(wrapper.vm.createNewInquiry.callCount).to.equal(4)
|
||||
})
|
||||
|
||||
it('Ctrl S calls checkInquiryBeforeSave if the tab is unsaved and route path is /workspace',
|
||||
async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
it('Ctrl S calls checkInquiryBeforeSave if the tab is unsaved and route path is /workspace', async () => {
|
||||
const tab = {
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const store = createStore({ state })
|
||||
const $route = { path: '/workspace' }
|
||||
|
||||
wrapper = shallowMount(MainMenu, {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: ['router-link'],
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
sinon.stub(wrapper.vm, 'checkInquiryBeforeSave')
|
||||
|
||||
const ctrlS = new KeyboardEvent('keydown', { key: 's', ctrlKey: true })
|
||||
const metaS = new KeyboardEvent('keydown', { key: 's', metaKey: true })
|
||||
// tab is unsaved and route is /workspace
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
|
||||
// tab is saved and route is /workspace
|
||||
store.state.tabs[0].isSaved = true
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
|
||||
// tab is unsaved and route is not /workspace
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
store.state.tabs[0].isSaved = false
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
})
|
||||
sinon.stub(wrapper.vm, 'checkInquiryBeforeSave')
|
||||
|
||||
it('Saves the inquiry when no need the new name',
|
||||
async () => {
|
||||
const tab = {
|
||||
id: 1,
|
||||
const ctrlS = new KeyboardEvent('keydown', { key: 's', ctrlKey: true })
|
||||
const metaS = new KeyboardEvent('keydown', { key: 's', metaKey: true })
|
||||
// tab is unsaved and route is /workspace
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledOnce).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
|
||||
// tab is saved and route is /workspace
|
||||
store.state.tabs[0].isSaved = true
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
|
||||
// tab is unsaved and route is not /workspace
|
||||
wrapper.vm.$route.path = '/inquiries'
|
||||
store.state.tabs[0].isSaved = false
|
||||
document.dispatchEvent(ctrlS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
document.dispatchEvent(metaS)
|
||||
expect(wrapper.vm.checkInquiryBeforeSave.calledTwice).to.equal(true)
|
||||
})
|
||||
|
||||
it('Saves the inquiry when no need the new name', async () => {
|
||||
const tab = {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const mutations = {
|
||||
updateTab: sinon.stub()
|
||||
}
|
||||
const actions = {
|
||||
saveInquiry: sinon.stub().returns({
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
execute: sinon.stub(),
|
||||
isSaved: false
|
||||
}
|
||||
const state = {
|
||||
currentTab: tab,
|
||||
tabs: [tab],
|
||||
db: {}
|
||||
}
|
||||
const mutations = {
|
||||
updateTab: sinon.stub()
|
||||
}
|
||||
const actions = {
|
||||
saveInquiry: sinon.stub().returns({
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: []
|
||||
})
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
const $route = { path: '/workspace' }
|
||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
||||
|
||||
wrapper = mount(MainMenu, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true, 'app-diagnostic-info': true,
|
||||
teleport: true, transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
viewType: 'chart',
|
||||
viewOptions: []
|
||||
})
|
||||
}
|
||||
const store = createStore({ state, mutations, actions })
|
||||
const $route = { path: '/workspace' }
|
||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
||||
|
||||
await wrapper.find('#save-btn').trigger('click')
|
||||
|
||||
// check that the dialog is closed
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
|
||||
// check that the inquiry was saved via saveInquiry (newName='')
|
||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab: state.currentTab, newName: ''
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
}))).to.equal(true)
|
||||
|
||||
// check that 'inquirySaved' event was triggered on eventBus
|
||||
expect(eventBus.$emit.calledOnceWith('inquirySaved')).to.equal(true)
|
||||
wrapper = mount(MainMenu, {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true,
|
||||
'app-diagnostic-info': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.find('#save-btn').trigger('click')
|
||||
|
||||
// check that the dialog is closed
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
|
||||
// check that the inquiry was saved via saveInquiry (newName='')
|
||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab: state.currentTab,
|
||||
newName: ''
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
expect(
|
||||
mutations.updateTab.calledOnceWith(
|
||||
state,
|
||||
sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
})
|
||||
)
|
||||
).to.equal(true)
|
||||
|
||||
// check that 'inquirySaved' event was triggered on eventBus
|
||||
expect(eventBus.$emit.calledOnceWith('inquirySaved')).to.equal(true)
|
||||
})
|
||||
|
||||
it('Shows en error when the new name is needed but not specifyied', async () => {
|
||||
const tab = {
|
||||
id: 1,
|
||||
@@ -477,8 +491,10 @@ describe('MainMenu.vue', () => {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true, 'app-diagnostic-info': true,
|
||||
teleport: true, transition: false
|
||||
'router-link': true,
|
||||
'app-diagnostic-info': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -488,8 +504,9 @@ describe('MainMenu.vue', () => {
|
||||
|
||||
// check that the dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Save inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Save inquiry'
|
||||
)
|
||||
|
||||
// find Save in the dialog and click
|
||||
await wrapper
|
||||
@@ -498,7 +515,9 @@ describe('MainMenu.vue', () => {
|
||||
.trigger('click')
|
||||
|
||||
// check that we have an error message and dialog is still open
|
||||
expect(wrapper.find('.text-field-error').text()).to.equal('Inquiry name can\'t be empty')
|
||||
expect(wrapper.find('.text-field-error').text()).to.equal(
|
||||
"Inquiry name can't be empty"
|
||||
)
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
})
|
||||
@@ -538,8 +557,10 @@ describe('MainMenu.vue', () => {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true, 'app-diagnostic-info': true,
|
||||
teleport: true, transition: false
|
||||
'router-link': true,
|
||||
'app-diagnostic-info': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -549,8 +570,9 @@ describe('MainMenu.vue', () => {
|
||||
|
||||
// check that the dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Save inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Save inquiry'
|
||||
)
|
||||
|
||||
// enter the new name
|
||||
await wrapper.find('.dialog-body input').setValue('foo')
|
||||
@@ -575,17 +597,22 @@ describe('MainMenu.vue', () => {
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
}))).to.equal(true)
|
||||
expect(
|
||||
mutations.updateTab.calledOnceWith(
|
||||
state,
|
||||
sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'foo',
|
||||
id: 1,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
})
|
||||
)
|
||||
).to.equal(true)
|
||||
|
||||
// check that 'inquirySaved' event was triggered on eventBus
|
||||
expect(eventBus.$emit.calledOnceWith('inquirySaved')).to.equal(true)
|
||||
@@ -635,8 +662,10 @@ describe('MainMenu.vue', () => {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true, 'app-diagnostic-info': true,
|
||||
teleport: true, transition: false
|
||||
'router-link': true,
|
||||
'app-diagnostic-info': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -646,8 +675,9 @@ describe('MainMenu.vue', () => {
|
||||
|
||||
// check that the dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Save inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Save inquiry'
|
||||
)
|
||||
|
||||
// check that save-note is visible (save-note is an explanation why do we need a new name)
|
||||
expect(wrapper.find('#save-note').isVisible()).to.equal(true)
|
||||
@@ -675,17 +705,22 @@ describe('MainMenu.vue', () => {
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'bar',
|
||||
id: 2,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
}))).to.equal(true)
|
||||
expect(
|
||||
mutations.updateTab.calledOnceWith(
|
||||
state,
|
||||
sinon.match({
|
||||
tab,
|
||||
newValues: {
|
||||
name: 'bar',
|
||||
id: 2,
|
||||
query: 'SELECT * FROM foo',
|
||||
viewType: 'chart',
|
||||
viewOptions: [],
|
||||
isSaved: true
|
||||
}
|
||||
})
|
||||
)
|
||||
).to.equal(true)
|
||||
|
||||
// check that 'inquirySaved' event was triggered on eventBus
|
||||
expect(eventBus.$emit.calledOnceWith('inquirySaved')).to.equal(true)
|
||||
@@ -738,8 +773,10 @@ describe('MainMenu.vue', () => {
|
||||
global: {
|
||||
mocks: { $route },
|
||||
stubs: {
|
||||
'router-link': true, 'app-diagnostic-info': true,
|
||||
teleport: true, transition: false
|
||||
'router-link': true,
|
||||
'app-diagnostic-info': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -749,8 +786,9 @@ describe('MainMenu.vue', () => {
|
||||
|
||||
// check that the dialog is open
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Save inquiry')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Save inquiry'
|
||||
)
|
||||
|
||||
// find Cancel in the dialog and click
|
||||
await wrapper
|
||||
|
||||
@@ -11,7 +11,6 @@ import fIo from '@/lib/utils/fileIo'
|
||||
import csv from '@/lib/csv'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
|
||||
describe('Schema.vue', () => {
|
||||
let clock
|
||||
|
||||
@@ -145,7 +144,10 @@ describe('Schema.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.findComponent({ name: 'export-icon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'export-icon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
expect(state.db.export.calledOnceWith('fooDB'))
|
||||
wrapper.unmount()
|
||||
})
|
||||
@@ -188,14 +190,18 @@ describe('Schema.vue', () => {
|
||||
sinon.spy(wrapper.vm, 'addCsvJson')
|
||||
sinon.spy(wrapper.vm.$refs.addCsvJson, 'loadToDb')
|
||||
|
||||
await wrapper.findComponent({ name: 'add-table-icon' }).find('svg').trigger('click')
|
||||
await wrapper
|
||||
.findComponent({ name: 'add-table-icon' })
|
||||
.find('svg')
|
||||
.trigger('click')
|
||||
await wrapper.vm.$refs.addCsvJson.preview.returnValues[0]
|
||||
await wrapper.vm.addCsvJson.returnValues[0]
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('CSV import')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'CSV import'
|
||||
)
|
||||
await wrapper.find('#import-start').trigger('click')
|
||||
await wrapper.vm.$refs.addCsvJson.loadToDb.returnValues[0]
|
||||
await wrapper.find('#import-finish').trigger('click')
|
||||
@@ -205,7 +211,13 @@ describe('Schema.vue', () => {
|
||||
|
||||
expect(wrapper.vm.$store.state.db.schema).to.eql([
|
||||
{ name: 'foo', columns: [{ name: 'id', type: 'N/A' }] },
|
||||
{ name: 'test', columns: [{ name: 'col1', type: 'REAL' }, { name: 'col2', type: 'TEXT' }] }
|
||||
{
|
||||
name: 'test',
|
||||
columns: [
|
||||
{ name: 'col1', type: 'REAL' },
|
||||
{ name: 'col2', type: 'TEXT' }
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
const res = await wrapper.vm.$store.state.db.execute('select * from test')
|
||||
|
||||
@@ -36,7 +36,11 @@ describe('TableDescription.vue', () => {
|
||||
|
||||
expect(wrapper.find('.columns').isVisible()).to.equal(true)
|
||||
expect(wrapper.findAll('.column').length).to.equal(2)
|
||||
expect(wrapper.findAll('.column')[0].text()).to.include('id').and.include('number')
|
||||
expect(wrapper.findAll('.column')[1].text()).to.include('title').and.include('nvarchar(24)')
|
||||
expect(wrapper.findAll('.column')[0].text())
|
||||
.to.include('id')
|
||||
.and.include('number')
|
||||
expect(wrapper.findAll('.column')[1].text())
|
||||
.to.include('title')
|
||||
.and.include('nvarchar(24)')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -12,9 +12,9 @@ describe('DataView.vue', () => {
|
||||
})
|
||||
|
||||
it('emits update on mode changing', async () => {
|
||||
const wrapper = mount(DataView, {
|
||||
const wrapper = mount(DataView, {
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -26,24 +26,32 @@ describe('DataView.vue', () => {
|
||||
})
|
||||
|
||||
it('method getOptionsForSave calls the same method of the current view component', async () => {
|
||||
const wrapper = mount(DataView, {
|
||||
const wrapper = mount(DataView, {
|
||||
global: {
|
||||
mocks: { $store }
|
||||
}
|
||||
})
|
||||
|
||||
const chart = wrapper.findComponent({ name: 'Chart' }).vm
|
||||
sinon.stub(chart, 'getOptionsForSave').returns({ here_are: 'chart_settings' })
|
||||
sinon
|
||||
.stub(chart, 'getOptionsForSave')
|
||||
.returns({ here_are: 'chart_settings' })
|
||||
|
||||
expect(wrapper.vm.getOptionsForSave()).to.eql({ here_are: 'chart_settings' })
|
||||
expect(wrapper.vm.getOptionsForSave()).to.eql({
|
||||
here_are: 'chart_settings'
|
||||
})
|
||||
|
||||
const pivotBtn = wrapper.findComponent({ ref: 'pivotBtn' })
|
||||
await pivotBtn.trigger('click')
|
||||
|
||||
const pivot = wrapper.findComponent({ name: 'pivot' }).vm
|
||||
sinon.stub(pivot, 'getOptionsForSave').returns({ here_are: 'pivot_settings' })
|
||||
sinon
|
||||
.stub(pivot, 'getOptionsForSave')
|
||||
.returns({ here_are: 'pivot_settings' })
|
||||
|
||||
expect(wrapper.vm.getOptionsForSave()).to.eql({ here_are: 'pivot_settings' })
|
||||
expect(wrapper.vm.getOptionsForSave()).to.eql({
|
||||
here_are: 'pivot_settings'
|
||||
})
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -117,7 +125,7 @@ describe('DataView.vue', () => {
|
||||
sinon.spy(window, 'alert')
|
||||
const wrapper = mount(DataView, {
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -127,8 +135,8 @@ describe('DataView.vue', () => {
|
||||
expect(
|
||||
window.alert.calledOnceWith(
|
||||
"Your browser doesn't support copying images into the clipboard. " +
|
||||
'If you use Firefox you can enable it ' +
|
||||
'by setting dom.events.asyncClipboard.clipboardItem to true.'
|
||||
'If you use Firefox you can enable it ' +
|
||||
'by setting dom.events.asyncClipboard.clipboardItem to true.'
|
||||
)
|
||||
).to.equal(true)
|
||||
|
||||
@@ -146,9 +154,11 @@ describe('DataView.vue', () => {
|
||||
mocks: { $store }
|
||||
}
|
||||
})
|
||||
sinon.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy').callsFake(async () => {
|
||||
await clock.tick(5000)
|
||||
})
|
||||
sinon
|
||||
.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy')
|
||||
.callsFake(async () => {
|
||||
await clock.tick(5000)
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = wrapper.findComponent({ ref: 'copyToClipboardBtn' })
|
||||
@@ -156,11 +166,14 @@ describe('DataView.vue', () => {
|
||||
|
||||
// The dialog is shown...
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Copy to clipboard')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Copy to clipboard'
|
||||
)
|
||||
|
||||
// ... with Rendering message...
|
||||
expect(wrapper.find('.dialog-body').text()).to.equal('Rendering the visualisation...')
|
||||
expect(wrapper.find('.dialog-body').text()).to.equal(
|
||||
'Rendering the visualisation...'
|
||||
)
|
||||
|
||||
// Switch to microtasks (let prepareCopy run)
|
||||
await clock.tick(0)
|
||||
@@ -177,7 +190,9 @@ describe('DataView.vue', () => {
|
||||
expect(wrapper.find('.dialog-body').text()).to.equal('Image is ready')
|
||||
|
||||
// Click copy
|
||||
await wrapper.find('.dialog-buttons-container button.primary').trigger('click')
|
||||
await wrapper
|
||||
.find('.dialog-buttons-container button.primary')
|
||||
.trigger('click')
|
||||
|
||||
// The dialog is not shown...
|
||||
await clock.tick(100)
|
||||
@@ -196,9 +211,11 @@ describe('DataView.vue', () => {
|
||||
}
|
||||
})
|
||||
sinon.spy(wrapper.vm, 'copyToClipboard')
|
||||
sinon.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy').callsFake(async () => {
|
||||
await clock.tick(500)
|
||||
})
|
||||
sinon
|
||||
.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy')
|
||||
.callsFake(async () => {
|
||||
await clock.tick(500)
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = wrapper.findComponent({ ref: 'copyToClipboardBtn' })
|
||||
@@ -229,9 +246,11 @@ describe('DataView.vue', () => {
|
||||
}
|
||||
})
|
||||
sinon.spy(wrapper.vm, 'copyToClipboard')
|
||||
sinon.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy').callsFake(async () => {
|
||||
await clock.tick(5000)
|
||||
})
|
||||
sinon
|
||||
.stub(wrapper.vm.$refs.viewComponent, 'prepareCopy')
|
||||
.callsFake(async () => {
|
||||
await clock.tick(5000)
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = wrapper.findComponent({ ref: 'copyToClipboardBtn' })
|
||||
@@ -245,7 +264,9 @@ describe('DataView.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
// Click cancel
|
||||
await wrapper.find('.dialog-buttons-container button.secondary').trigger('click')
|
||||
await wrapper
|
||||
.find('.dialog-buttons-container button.secondary')
|
||||
.trigger('click')
|
||||
|
||||
// The dialog is not shown...
|
||||
await clock.tick(100)
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
},
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
const colLabels = wrapper.findAll('.pivot-output thead th.pvtColLabel')
|
||||
@@ -77,7 +77,7 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
},
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -144,7 +144,11 @@ describe('Pivot.vue', () => {
|
||||
rendererName: 'Table',
|
||||
vals: []
|
||||
})
|
||||
sinon.stub(wrapper.findComponent({ref: "customChart"}).vm, 'getOptionsForSave')
|
||||
sinon
|
||||
.stub(
|
||||
wrapper.findComponent({ ref: 'customChart' }).vm,
|
||||
'getOptionsForSave'
|
||||
)
|
||||
.returns({ here_are: 'custom chart settings' })
|
||||
|
||||
let optionsForSave = wrapper.vm.getOptionsForSave()
|
||||
@@ -208,7 +212,8 @@ describe('Pivot.vue', () => {
|
||||
|
||||
expect(await wrapper.vm.prepareCopy()).to.be.instanceof(HTMLCanvasElement)
|
||||
|
||||
sinon.stub(wrapper.findComponent({ref: "customChart"}).vm, 'prepareCopy')
|
||||
sinon
|
||||
.stub(wrapper.findComponent({ ref: 'customChart' }).vm, 'prepareCopy')
|
||||
.returns(URL.createObjectURL(new Blob()))
|
||||
|
||||
await wrapper.findComponent({ name: 'pivotUi' }).setValue({
|
||||
@@ -271,7 +276,7 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const chartComponent = wrapper.findComponent({ref: "customChart"}).vm
|
||||
const chartComponent = wrapper.findComponent({ ref: 'customChart' }).vm
|
||||
sinon.stub(chartComponent, 'saveAsSvg')
|
||||
|
||||
await wrapper.vm.saveAsSvg()
|
||||
@@ -309,7 +314,7 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const chartComponent = wrapper.findComponent({ref: "customChart"}).vm
|
||||
const chartComponent = wrapper.findComponent({ ref: 'customChart' }).vm
|
||||
sinon.stub(chartComponent, 'saveAsHtml')
|
||||
|
||||
await wrapper.vm.saveAsHtml()
|
||||
@@ -347,7 +352,7 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const chartComponent = wrapper.findComponent({ref: "customChart"}).vm
|
||||
const chartComponent = wrapper.findComponent({ ref: 'customChart' }).vm
|
||||
sinon.stub(chartComponent, 'saveAsPng')
|
||||
|
||||
await wrapper.vm.saveAsPng()
|
||||
@@ -376,7 +381,7 @@ describe('Pivot.vue', () => {
|
||||
},
|
||||
attachTo: container,
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -407,7 +412,7 @@ describe('Pivot.vue', () => {
|
||||
},
|
||||
attachTo: container,
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -440,14 +445,16 @@ describe('Pivot.vue', () => {
|
||||
},
|
||||
attachTo: container,
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.vm.saveAsHtml()
|
||||
expect(pivotHelper.getPivotHtml.calledOnce).to.equal(true)
|
||||
const html = pivotHelper.getPivotHtml.returnValues[0]
|
||||
expect(fIo.exportToFile.calledOnceWith(html, 'pivot.html', 'text/html')).to.equal(true)
|
||||
expect(
|
||||
fIo.exportToFile.calledOnceWith(html, 'pivot.html', 'text/html')
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('saveAsPng - standart chart', async () => {
|
||||
@@ -473,7 +480,7 @@ describe('Pivot.vue', () => {
|
||||
},
|
||||
attachTo: container,
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -481,12 +488,18 @@ describe('Pivot.vue', () => {
|
||||
expect(chartHelper.getImageDataUrl.calledOnce).to.equal(true)
|
||||
await chartHelper.getImageDataUrl.returnValues[0]
|
||||
expect(wrapper.emitted().loadingImageCompleted.length).to.equal(1)
|
||||
expect(fIo.downloadFromUrl.calledOnceWith('standat chart data url', 'pivot')).to.equal(true)
|
||||
expect(
|
||||
fIo.downloadFromUrl.calledOnceWith('standat chart data url', 'pivot')
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('saveAsPng - table', async () => {
|
||||
sinon.stub(pivotHelper, 'getPivotCanvas').returns(document.createElement('canvas'))
|
||||
sinon.stub(HTMLCanvasElement.prototype, 'toDataURL').returns('canvas data url')
|
||||
sinon
|
||||
.stub(pivotHelper, 'getPivotCanvas')
|
||||
.returns(document.createElement('canvas'))
|
||||
sinon
|
||||
.stub(HTMLCanvasElement.prototype, 'toDataURL')
|
||||
.returns('canvas data url')
|
||||
sinon.stub(fIo, 'downloadFromUrl')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
@@ -508,7 +521,7 @@ describe('Pivot.vue', () => {
|
||||
},
|
||||
attachTo: container,
|
||||
global: {
|
||||
stubs: { 'chart': true }
|
||||
stubs: { chart: true }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -516,6 +529,8 @@ describe('Pivot.vue', () => {
|
||||
expect(HTMLCanvasElement.prototype.toDataURL.calledOnce).to.equal(true)
|
||||
await HTMLCanvasElement.prototype.toDataURL.returnValues[0]
|
||||
expect(wrapper.emitted().loadingImageCompleted.length).to.equal(1)
|
||||
expect(fIo.downloadFromUrl.calledOnceWith('canvas data url', 'pivot')).to.equal(true)
|
||||
expect(
|
||||
fIo.downloadFromUrl.calledOnceWith('canvas data url', 'pivot')
|
||||
).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,10 +4,10 @@ import PivotSortBtn from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot/PivotUi
|
||||
|
||||
describe('PivotSortBtn.vue', () => {
|
||||
it('switches order', async () => {
|
||||
const wrapper = shallowMount(PivotSortBtn, {
|
||||
const wrapper = shallowMount(PivotSortBtn, {
|
||||
props: {
|
||||
modelValue: 'key_a_to_z',
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -7,16 +7,17 @@ describe('PivotUi.vue', () => {
|
||||
const wrapper = mount(PivotUi, {
|
||||
props: {
|
||||
keyNames: ['foo', 'bar'],
|
||||
'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e })
|
||||
'onUpdate:modelValue': e => wrapper.setProps({ modelValue: e })
|
||||
}
|
||||
})
|
||||
|
||||
// choose columns
|
||||
await wrapper.findAll('.sqliteviz-select.cols .multiselect__element > span')[0]
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.cols .multiselect__element > span')[0]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(1)
|
||||
|
||||
|
||||
let value = wrapper.props('modelValue')
|
||||
expect(value.rows).to.eql([])
|
||||
expect(value.cols).to.eql(['foo'])
|
||||
@@ -28,7 +29,8 @@ describe('PivotUi.vue', () => {
|
||||
expect(value.vals).to.eql([])
|
||||
|
||||
// choose rows
|
||||
await wrapper.findAll('.sqliteviz-select.rows .multiselect__element > span')[0]
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.rows .multiselect__element > span')[0]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(2)
|
||||
@@ -71,7 +73,8 @@ describe('PivotUi.vue', () => {
|
||||
expect(value.vals).to.eql([])
|
||||
|
||||
// change aggregator
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[12]
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[12]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(5)
|
||||
@@ -120,7 +123,8 @@ describe('PivotUi.vue', () => {
|
||||
expect(value.vals).to.eql(['foo', 'bar'])
|
||||
|
||||
// change renderer
|
||||
await wrapper.findAll('.sqliteviz-select.renderer .multiselect__element > span')[13]
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.renderer .multiselect__element > span')[13]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(8)
|
||||
@@ -134,7 +138,8 @@ describe('PivotUi.vue', () => {
|
||||
expect(value.vals).to.eql(['foo', 'bar'])
|
||||
|
||||
// change aggregator again
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[3]
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[3]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(9)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { expect } from 'chai'
|
||||
import { _getDataSources, getPivotCanvas, getPivotHtml }
|
||||
from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot/pivotHelper'
|
||||
import {
|
||||
_getDataSources,
|
||||
getPivotCanvas,
|
||||
getPivotHtml
|
||||
} from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot/pivotHelper'
|
||||
|
||||
describe('pivotHelper.js', () => {
|
||||
it('_getDataSources returns data sources', () => {
|
||||
@@ -22,10 +25,10 @@ describe('pivotHelper.js', () => {
|
||||
const pivotData = {
|
||||
rowAttrs: ['y'],
|
||||
colAttrs: ['x', 'z'],
|
||||
getRowKeys () {
|
||||
getRowKeys() {
|
||||
return [[3], [6], [9]]
|
||||
},
|
||||
getColKeys () {
|
||||
getColKeys() {
|
||||
return [
|
||||
[5, 2],
|
||||
[5, 3],
|
||||
@@ -33,9 +36,9 @@ describe('pivotHelper.js', () => {
|
||||
[10, 6]
|
||||
]
|
||||
},
|
||||
getAggregator (row, col) {
|
||||
getAggregator(row, col) {
|
||||
return {
|
||||
value () {
|
||||
value() {
|
||||
return +row + +col[1]
|
||||
}
|
||||
}
|
||||
@@ -61,7 +64,9 @@ describe('pivotHelper.js', () => {
|
||||
child.classList.add('pvtTable')
|
||||
pivotOutput.append(child)
|
||||
|
||||
expect(await getPivotCanvas(pivotOutput)).to.be.instanceof(HTMLCanvasElement)
|
||||
expect(await getPivotCanvas(pivotOutput)).to.be.instanceof(
|
||||
HTMLCanvasElement
|
||||
)
|
||||
})
|
||||
|
||||
it('getPivotHtml returns html with styles', async () => {
|
||||
|
||||
@@ -25,8 +25,9 @@ describe('Record.vue', () => {
|
||||
expect(rows[1].findAll('th')[0].text()).to.equals('name')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('bar')
|
||||
|
||||
const selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
const selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('bar')
|
||||
})
|
||||
|
||||
@@ -49,8 +50,9 @@ describe('Record.vue', () => {
|
||||
expect(rows).to.have.lengthOf(2)
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('1')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('foo')
|
||||
let selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
let selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
|
||||
await wrapper.find('.next').trigger('click')
|
||||
@@ -58,8 +60,9 @@ describe('Record.vue', () => {
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('2')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('bar')
|
||||
selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('2')
|
||||
|
||||
await wrapper.find('.prev').trigger('click')
|
||||
@@ -67,8 +70,9 @@ describe('Record.vue', () => {
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('1')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('foo')
|
||||
selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
|
||||
await wrapper.find('.last').trigger('click')
|
||||
@@ -76,8 +80,9 @@ describe('Record.vue', () => {
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('3')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('baz')
|
||||
selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('3')
|
||||
|
||||
await wrapper.find('.first').trigger('click')
|
||||
@@ -85,8 +90,9 @@ describe('Record.vue', () => {
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('1')
|
||||
expect(rows[1].findAll('td')[0].text()).to.equals('foo')
|
||||
selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
})
|
||||
|
||||
@@ -105,12 +111,14 @@ describe('Record.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
const selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
await selectedCell.trigger('click')
|
||||
|
||||
const selectedCellAfterClick = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
const selectedCellAfterClick = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCellAfterClick.exists()).to.equals(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -39,8 +39,8 @@ describe('RunResult.vue', () => {
|
||||
expect(
|
||||
window.alert.calledOnceWith(
|
||||
"Your browser doesn't support copying into the clipboard. " +
|
||||
'If you use Firefox you can enable it ' +
|
||||
'by setting dom.events.asyncClipboard.clipboardItem to true.'
|
||||
'If you use Firefox you can enable it ' +
|
||||
'by setting dom.events.asyncClipboard.clipboardItem to true.'
|
||||
)
|
||||
).to.equal(true)
|
||||
|
||||
@@ -79,8 +79,9 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// The dialog is shown...
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(true)
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text())
|
||||
.to.contain('Copy to clipboard')
|
||||
expect(wrapper.find('.dialog.vfm .dialog-header').text()).to.contain(
|
||||
'Copy to clipboard'
|
||||
)
|
||||
|
||||
// ... with Building message...
|
||||
expect(wrapper.find('.dialog-body').text()).to.equal('Building CSV...')
|
||||
@@ -96,7 +97,9 @@ describe('RunResult.vue', () => {
|
||||
expect(wrapper.find('.dialog-body').text()).to.equal('CSV is ready')
|
||||
|
||||
// Click copy
|
||||
await wrapper.find('.dialog-buttons-container button.primary').trigger('click')
|
||||
await wrapper
|
||||
.find('.dialog-buttons-container button.primary')
|
||||
.trigger('click')
|
||||
await window.navigator.clipboard.writeText.returnValues[0]
|
||||
|
||||
// The dialog is not shown...
|
||||
@@ -180,7 +183,9 @@ describe('RunResult.vue', () => {
|
||||
await nextTick()
|
||||
|
||||
// Click cancel
|
||||
await wrapper.find('.dialog-buttons-container button.secondary').trigger('click')
|
||||
await wrapper
|
||||
.find('.dialog-buttons-container button.secondary')
|
||||
.trigger('click')
|
||||
// The dialog is not shown...
|
||||
await clock.tick(100)
|
||||
expect(wrapper.find('.dialog.vfm').exists()).to.equal(false)
|
||||
@@ -246,8 +251,9 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// Click on 'bar' cell again
|
||||
await rows[1].findAll('td')[1].trigger('click')
|
||||
expect(wrapper.find('.value-viewer-container .table-preview').text())
|
||||
.to.equals('No cell selected to view')
|
||||
expect(
|
||||
wrapper.find('.value-viewer-container .table-preview').text()
|
||||
).to.equals('No cell selected to view')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -318,8 +324,9 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// Click on 'foo' cell again
|
||||
await rows[1].find('td').trigger('click')
|
||||
expect(wrapper.find('.value-viewer-container .table-preview').text())
|
||||
.to.equals('No cell selected to view')
|
||||
expect(
|
||||
wrapper.find('.value-viewer-container .table-preview').text()
|
||||
).to.equals('No cell selected to view')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -357,8 +364,9 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// 'name-1' is selected
|
||||
expect(wrapper.find('.value-body').text()).to.equals('name-1')
|
||||
let selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
let selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('name-1')
|
||||
|
||||
// Go to last record
|
||||
@@ -375,8 +383,9 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// '29' is selected
|
||||
expect(wrapper.find('.value-body').text()).to.equals('29')
|
||||
selectedCell = wrapper
|
||||
.find('.sqliteviz-table tbody td[aria-selected="true"]')
|
||||
selectedCell = wrapper.find(
|
||||
'.sqliteviz-table tbody td[aria-selected="true"]'
|
||||
)
|
||||
expect(selectedCell.text()).to.equals('29')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('ValueViewer.vue', () => {
|
||||
}
|
||||
})
|
||||
await wrapper.find('button.json').trigger('click')
|
||||
expect(wrapper.find('.value-body').text()).to.equals('Can\'t parse JSON.')
|
||||
expect(wrapper.find('.value-body').text()).to.equals("Can't parse JSON.")
|
||||
})
|
||||
|
||||
it('copy to clipboard', async () => {
|
||||
@@ -38,7 +38,8 @@ describe('ValueViewer.vue', () => {
|
||||
|
||||
await wrapper.find('button.copy').trigger('click')
|
||||
|
||||
expect(window.navigator.clipboard.writeText.calledOnceWith('foo'))
|
||||
.to.equal(true)
|
||||
expect(window.navigator.clipboard.writeText.calledOnceWith('foo')).to.equal(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -18,8 +18,12 @@ describe('SqlEditor.vue', () => {
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
await wrapper.findComponent({ ref: 'cm' }).setValue('SELECT * FROM foo', 'value')
|
||||
expect(wrapper.emitted()['update:modelValue'][0]).to.eql(['SELECT * FROM foo'])
|
||||
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 () => {
|
||||
@@ -28,11 +32,13 @@ describe('SqlEditor.vue', () => {
|
||||
}
|
||||
const store = createStore({ state })
|
||||
|
||||
const wrapper = mount(SqlEditor, {
|
||||
const wrapper = mount(SqlEditor, {
|
||||
global: { plugins: [store] },
|
||||
props: { isGettingResults: false }
|
||||
})
|
||||
await wrapper.findComponent({ ref: 'cm' }).setValue('SELECT * FROM foo', 'value')
|
||||
await wrapper
|
||||
.findComponent({ ref: 'cm' })
|
||||
.setValue('SELECT * FROM foo', 'value')
|
||||
const runButton = wrapper.findComponent({ ref: 'runBtn' })
|
||||
|
||||
expect(runButton.props('disabled')).to.equal(true)
|
||||
@@ -44,7 +50,9 @@ describe('SqlEditor.vue', () => {
|
||||
await wrapper.findComponent({ ref: 'cm' }).setValue('', 'value')
|
||||
expect(runButton.props('disabled')).to.equal(true)
|
||||
|
||||
await wrapper.findComponent({ ref: 'cm' }).setValue('SELECT * FROM foo', 'value')
|
||||
await wrapper
|
||||
.findComponent({ ref: 'cm' })
|
||||
.setValue('SELECT * FROM foo', 'value')
|
||||
expect(runButton.props('disabled')).to.equal(false)
|
||||
|
||||
await wrapper.setProps({ isGettingResults: true })
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import state from '@/store/state'
|
||||
import showHint, { getHints } from '@/views/Main/Workspace/Tabs/Tab/SqlEditor/hint'
|
||||
import showHint, {
|
||||
getHints
|
||||
} from '@/views/Main/Workspace/Tabs/Tab/SqlEditor/hint'
|
||||
import CM from 'codemirror'
|
||||
|
||||
describe('hint.js', () => {
|
||||
@@ -22,9 +24,7 @@ describe('hint.js', () => {
|
||||
},
|
||||
{
|
||||
name: 'bar',
|
||||
columns: [
|
||||
{ name: 'barId', type: 'INTEGER' }
|
||||
]
|
||||
columns: [{ name: 'barId', type: 'INTEGER' }]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -33,7 +33,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: 'SELECT',
|
||||
type: 'keyword'
|
||||
@@ -70,7 +70,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: 'SELECT',
|
||||
type: 'keyword'
|
||||
@@ -87,7 +87,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: 'foo',
|
||||
type: 'string'
|
||||
@@ -104,7 +104,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: ' ',
|
||||
type: null
|
||||
@@ -121,7 +121,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: ';',
|
||||
type: 'punctuation'
|
||||
@@ -134,30 +134,27 @@ describe('hint.js', () => {
|
||||
expect(CM.showHint.called).to.equal(false)
|
||||
})
|
||||
|
||||
it(
|
||||
'getHints returns [ ] if there is only one option and token is completed with this option',
|
||||
() => {
|
||||
// mock CM.hint.sql and editor
|
||||
sinon.stub(CM.hint, 'sql').returns({
|
||||
list: [{ text: 'SELECT' }],
|
||||
from: null, // from/to doesn't metter because getRange is mocked
|
||||
to: null
|
||||
})
|
||||
it('getHints returns [ ] if there is only one option and token is completed with this option', () => {
|
||||
// mock CM.hint.sql and editor
|
||||
sinon.stub(CM.hint, 'sql').returns({
|
||||
list: [{ text: 'SELECT' }],
|
||||
from: null, // from/to doesn't metter because getRange is mocked
|
||||
to: null
|
||||
})
|
||||
|
||||
const editor = {
|
||||
getRange () {
|
||||
return 'select'
|
||||
}
|
||||
const editor = {
|
||||
getRange() {
|
||||
return 'select'
|
||||
}
|
||||
|
||||
const hints = getHints(editor, {})
|
||||
expect(hints.list).to.eql([])
|
||||
}
|
||||
)
|
||||
|
||||
const hints = getHints(editor, {})
|
||||
expect(hints.list).to.eql([])
|
||||
})
|
||||
|
||||
it(
|
||||
'getHints returns [ ] if there is only one string option and token ' +
|
||||
'is completed with this option',
|
||||
'is completed with this option',
|
||||
() => {
|
||||
// mock CM.hint.sql and editor
|
||||
sinon.stub(CM.hint, 'sql').returns({
|
||||
@@ -166,7 +163,7 @@ describe('hint.js', () => {
|
||||
to: null
|
||||
})
|
||||
const editor = {
|
||||
getRange () {
|
||||
getRange() {
|
||||
return 'house.name'
|
||||
}
|
||||
}
|
||||
@@ -178,13 +175,10 @@ describe('hint.js', () => {
|
||||
|
||||
it('getHints returns hints as is when there are more than one option', () => {
|
||||
// mock CM.hint.sql and editor
|
||||
const list = [
|
||||
{ text: 'SELECT' },
|
||||
{ text: 'ST' }
|
||||
]
|
||||
const list = [{ text: 'SELECT' }, { text: 'ST' }]
|
||||
sinon.stub(CM.hint, 'sql').returns({ list, from: null, to: null })
|
||||
const editor = {
|
||||
getRange () {
|
||||
getRange() {
|
||||
return 'se'
|
||||
}
|
||||
}
|
||||
@@ -195,22 +189,19 @@ describe('hint.js', () => {
|
||||
sinon.restore()
|
||||
})
|
||||
|
||||
it(
|
||||
'getHints returns hints as is when there only one option but the token is not completed',
|
||||
() => {
|
||||
// mock CM.hint.sql and editor
|
||||
const list = [{ text: 'SELECT' }]
|
||||
sinon.stub(CM.hint, 'sql').returns({ list, from: null, to: null })
|
||||
const editor = {
|
||||
getRange () {
|
||||
return 'sele'
|
||||
}
|
||||
it('getHints returns hints as is when there only one option but the token is not completed', () => {
|
||||
// mock CM.hint.sql and editor
|
||||
const list = [{ text: 'SELECT' }]
|
||||
sinon.stub(CM.hint, 'sql').returns({ list, from: null, to: null })
|
||||
const editor = {
|
||||
getRange() {
|
||||
return 'sele'
|
||||
}
|
||||
|
||||
const hints = getHints(editor, {})
|
||||
expect(hints.list).to.eql(list)
|
||||
}
|
||||
)
|
||||
|
||||
const hints = getHints(editor, {})
|
||||
expect(hints.list).to.eql(list)
|
||||
})
|
||||
|
||||
it('tables is empty object when schema is null', () => {
|
||||
// mock store state
|
||||
@@ -219,7 +210,7 @@ describe('hint.js', () => {
|
||||
// mock showHint and editor
|
||||
sinon.stub(CM, 'showHint')
|
||||
const editor = {
|
||||
getTokenAt () {
|
||||
getTokenAt() {
|
||||
return {
|
||||
string: 'SELECT',
|
||||
type: 'keyword'
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true, 'icon-button': true },
|
||||
stubs: { chart: true, 'icon-button': true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -56,10 +56,15 @@ describe('Tab.vue', () => {
|
||||
})
|
||||
await nextTick()
|
||||
expect(wrapper.find('.tab-content-container').isVisible()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .run-result-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.run-result-panel .result-before').isVisible()).to.equal(true)
|
||||
expect(wrapper.find('.above .sql-editor-panel .codemirror-container').text())
|
||||
.to.contain('SELECT * FROM foo')
|
||||
expect(wrapper.find('.bottomPane .run-result-panel').exists()).to.equal(
|
||||
true
|
||||
)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-before').isVisible()
|
||||
).to.equal(true)
|
||||
expect(
|
||||
wrapper.find('.above .sql-editor-panel .codemirror-container').text()
|
||||
).to.contain('SELECT * FROM foo')
|
||||
})
|
||||
|
||||
it("Doesn't render tab when it's not active", async () => {
|
||||
@@ -74,7 +79,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -114,7 +119,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -174,7 +179,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -219,7 +224,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -263,7 +268,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true, 'icon-button': true },
|
||||
stubs: { chart: true, 'icon-button': true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -274,7 +279,9 @@ describe('Tab.vue', () => {
|
||||
|
||||
store.state.tabs[0].isGettingResults = true
|
||||
await nextTick()
|
||||
expect(wrapper.find('.run-result-panel .result-in-progress').exists()).to.equal(true)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-in-progress').exists()
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('Shows error when executing query ends with error', async () => {
|
||||
@@ -310,7 +317,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true, 'icon-button': true, },
|
||||
stubs: { chart: true, 'icon-button': true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -323,10 +330,16 @@ describe('Tab.vue', () => {
|
||||
message: 'There is no table foo'
|
||||
}
|
||||
await nextTick()
|
||||
expect(wrapper.find('.run-result-panel .result-before').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('.run-result-panel .result-in-progress').exists()).to.equal(false)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-before').isVisible()
|
||||
).to.equal(false)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-in-progress').exists()
|
||||
).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).isVisible()).to.equal(true)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include('There is no table foo')
|
||||
expect(wrapper.findComponent({ name: 'logs' }).text()).to.include(
|
||||
'There is no table foo'
|
||||
)
|
||||
})
|
||||
|
||||
it('Passes result to sql-table component', async () => {
|
||||
@@ -368,7 +381,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -378,10 +391,16 @@ describe('Tab.vue', () => {
|
||||
await nextTick()
|
||||
store.state.tabs[0].result = result
|
||||
await nextTick()
|
||||
expect(wrapper.find('.run-result-panel .result-before').isVisible()).to.equal(false)
|
||||
expect(wrapper.find('.run-result-panel .result-in-progress').exists()).to.equal(false)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-before').isVisible()
|
||||
).to.equal(false)
|
||||
expect(
|
||||
wrapper.find('.run-result-panel .result-in-progress').exists()
|
||||
).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'logs' }).exists()).to.equal(false)
|
||||
expect(wrapper.findComponent({ name: 'SqlTable' }).vm.dataSet).to.eql(result)
|
||||
expect(wrapper.findComponent({ name: 'SqlTable' }).vm.dataSet).to.eql(
|
||||
result
|
||||
)
|
||||
})
|
||||
|
||||
it('Switches views', async () => {
|
||||
@@ -414,7 +433,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -422,33 +441,43 @@ describe('Tab.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
let tableBtn = wrapper.find('.above .side-tool-bar')
|
||||
let tableBtn = wrapper
|
||||
.find('.above .side-tool-bar')
|
||||
.findComponent({ ref: 'tableBtn' })
|
||||
await tableBtn.vm.$emit('click')
|
||||
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('.above .run-result-panel').exists()).to.equal(true)
|
||||
|
||||
const dataViewBtn = wrapper.find('.above .side-tool-bar')
|
||||
const dataViewBtn = wrapper
|
||||
.find('.above .side-tool-bar')
|
||||
.findComponent({ ref: 'dataViewBtn' })
|
||||
await dataViewBtn.vm.$emit('click')
|
||||
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(
|
||||
true
|
||||
)
|
||||
expect(wrapper.find('.above .data-view-panel').exists()).to.equal(true)
|
||||
|
||||
const sqlEditorBtn = wrapper.find('.above .side-tool-bar')
|
||||
const sqlEditorBtn = wrapper
|
||||
.find('.above .side-tool-bar')
|
||||
.findComponent({ ref: 'sqlEditorBtn' })
|
||||
await sqlEditorBtn.vm.$emit('click')
|
||||
|
||||
expect(wrapper.find('.above .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .data-view-panel').exists()).to.equal(true)
|
||||
|
||||
tableBtn = wrapper.find('.bottomPane .side-tool-bar')
|
||||
tableBtn = wrapper
|
||||
.find('.bottomPane .side-tool-bar')
|
||||
.findComponent({ ref: 'tableBtn' })
|
||||
await tableBtn.vm.$emit('click')
|
||||
|
||||
expect(wrapper.find('.above .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .run-result-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .run-result-panel').exists()).to.equal(
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
it('Maximize top panel if maximized panel is above', async () => {
|
||||
@@ -480,7 +509,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -489,8 +518,9 @@ describe('Tab.vue', () => {
|
||||
})
|
||||
await nextTick()
|
||||
|
||||
expect(wrapper.find('.above').element.parentElement.style.height)
|
||||
.to.equal('100%')
|
||||
expect(wrapper.find('.above').element.parentElement.style.height).to.equal(
|
||||
'100%'
|
||||
)
|
||||
})
|
||||
|
||||
it('Maximize bottom panel if maximized panel is below', async () => {
|
||||
@@ -522,7 +552,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -530,8 +560,9 @@ describe('Tab.vue', () => {
|
||||
}
|
||||
})
|
||||
await nextTick()
|
||||
expect(wrapper.find('.bottomPane').element.parentElement.style.height)
|
||||
.to.equal('100%')
|
||||
expect(
|
||||
wrapper.find('.bottomPane').element.parentElement.style.height
|
||||
).to.equal('100%')
|
||||
})
|
||||
|
||||
it('Panel size is 50 if nothing to maximize', async () => {
|
||||
@@ -562,7 +593,7 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
global: {
|
||||
stubs: { 'chart': true },
|
||||
stubs: { chart: true },
|
||||
plugins: [store]
|
||||
},
|
||||
props: {
|
||||
@@ -571,9 +602,11 @@ describe('Tab.vue', () => {
|
||||
})
|
||||
|
||||
await nextTick()
|
||||
expect(wrapper.find('.above').element.parentElement.style.height)
|
||||
.to.equal('50%')
|
||||
expect(wrapper.find('.bottomPane').element.parentElement.style.height)
|
||||
.to.equal('50%')
|
||||
expect(wrapper.find('.above').element.parentElement.style.height).to.equal(
|
||||
'50%'
|
||||
)
|
||||
expect(
|
||||
wrapper.find('.bottomPane').element.parentElement.style.height
|
||||
).to.equal('50%')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -6,10 +6,9 @@ import { createStore } from 'vuex'
|
||||
import Tabs from '@/views/Main/Workspace/Tabs'
|
||||
import eventBus from '@/lib/eventBus'
|
||||
|
||||
|
||||
describe('Tabs.vue', () => {
|
||||
let clock
|
||||
|
||||
|
||||
beforeEach(() => {
|
||||
clock = sinon.useFakeTimers()
|
||||
sinon.spy(eventBus, '$emit')
|
||||
@@ -43,8 +42,21 @@ describe('Tabs.vue', () => {
|
||||
// mock store state
|
||||
const state = {
|
||||
tabs: [
|
||||
{ id: 1, name: 'foo', query: 'select * from foo', chart: [], isSaved: true },
|
||||
{ id: 2, name: null, tempName: 'Untitled', query: '', chart: [], isSaved: false }
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
chart: [],
|
||||
isSaved: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: null,
|
||||
tempName: 'Untitled',
|
||||
query: '',
|
||||
chart: [],
|
||||
isSaved: false
|
||||
}
|
||||
],
|
||||
currentTabId: 2
|
||||
}
|
||||
@@ -81,8 +93,21 @@ describe('Tabs.vue', () => {
|
||||
// mock store state
|
||||
const state = {
|
||||
tabs: [
|
||||
{ id: 1, name: 'foo', query: 'select * from foo', chart: [], isSaved: true },
|
||||
{ id: 2, name: null, tempName: 'Untitled', query: '', chart: [], isSaved: false }
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
chart: [],
|
||||
isSaved: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: null,
|
||||
tempName: 'Untitled',
|
||||
query: '',
|
||||
chart: [],
|
||||
isSaved: false
|
||||
}
|
||||
],
|
||||
currentTabId: 2
|
||||
}
|
||||
@@ -210,7 +235,9 @@ describe('Tabs.vue', () => {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
stubs: {
|
||||
'router-link': true, teleport: true, transition: false
|
||||
'router-link': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -284,7 +311,9 @@ describe('Tabs.vue', () => {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
stubs: {
|
||||
'router-link': true, teleport: true, transition: false
|
||||
'router-link': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -360,7 +389,9 @@ describe('Tabs.vue', () => {
|
||||
attachTo: document.body,
|
||||
global: {
|
||||
stubs: {
|
||||
'router-link': true, teleport: true, transition: false
|
||||
'router-link': true,
|
||||
teleport: true,
|
||||
transition: false
|
||||
},
|
||||
plugins: [store]
|
||||
}
|
||||
@@ -401,8 +432,21 @@ describe('Tabs.vue', () => {
|
||||
// mock store state
|
||||
const state = {
|
||||
tabs: [
|
||||
{ id: 1, name: 'foo', query: 'select * from foo', chart: [], isSaved: true },
|
||||
{ id: 2, name: null, tempName: 'Untitled', query: '', chart: [], isSaved: false }
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
chart: [],
|
||||
isSaved: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: null,
|
||||
tempName: 'Untitled',
|
||||
query: '',
|
||||
chart: [],
|
||||
isSaved: false
|
||||
}
|
||||
],
|
||||
currentTabId: 2
|
||||
}
|
||||
@@ -429,7 +473,13 @@ describe('Tabs.vue', () => {
|
||||
// mock store state
|
||||
const state = {
|
||||
tabs: [
|
||||
{ id: 1, name: 'foo', query: 'select * from foo', chart: [], isSaved: true }
|
||||
{
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
query: 'select * from foo',
|
||||
chart: [],
|
||||
isSaved: true
|
||||
}
|
||||
],
|
||||
currentTabId: 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user