mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
update tests
This commit is contained in:
@@ -37,7 +37,7 @@ describe('Chart.vue', () => {
|
||||
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Chart, {
|
||||
propsData: { dataSources }
|
||||
props: { dataSources }
|
||||
})
|
||||
|
||||
const newDataSources = {
|
||||
@@ -58,7 +58,7 @@ describe('Chart.vue', () => {
|
||||
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Chart, {
|
||||
propsData: { dataSources }
|
||||
props: { dataSources }
|
||||
})
|
||||
|
||||
await wrapper.setProps({ dataSources: null })
|
||||
@@ -73,7 +73,7 @@ describe('Chart.vue', () => {
|
||||
}
|
||||
|
||||
const wrapper = mount(Chart, {
|
||||
propsData: { dataSources }
|
||||
props: { dataSources }
|
||||
})
|
||||
sinon.spy(wrapper.vm, 'prepareCopy')
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect } from 'chai'
|
||||
import { mount, createWrapper } from '@vue/test-utils'
|
||||
import { mount, DOMWrapper } from '@vue/test-utils'
|
||||
import DataView from '@/views/Main/Workspace/Tabs/Tab/DataView'
|
||||
import sinon from 'sinon'
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('DataView.vue', () => {
|
||||
it('emits update on mode changing', async () => {
|
||||
const wrapper = mount(DataView)
|
||||
|
||||
const pivotBtn = createWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
const pivotBtn = new DOMWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
await pivotBtn.trigger('click')
|
||||
|
||||
expect(wrapper.emitted('update')).to.have.lengthOf(1)
|
||||
@@ -25,7 +25,7 @@ describe('DataView.vue', () => {
|
||||
|
||||
expect(wrapper.vm.getOptionsForSave()).to.eql({ here_are: 'chart_settings' })
|
||||
|
||||
const pivotBtn = createWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
const pivotBtn = new DOMWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
await pivotBtn.trigger('click')
|
||||
|
||||
const pivot = wrapper.findComponent({ name: 'pivot' }).vm
|
||||
@@ -42,12 +42,12 @@ describe('DataView.vue', () => {
|
||||
sinon.spy(chart, 'saveAsSvg')
|
||||
|
||||
// Export to svg
|
||||
const svgBtn = createWrapper(wrapper.findComponent({ name: 'exportToSvgIcon' }).vm.$parent)
|
||||
const svgBtn = new DOMWrapper(wrapper.findComponent({ name: 'exportToSvgIcon' }).vm.$parent)
|
||||
await svgBtn.trigger('click')
|
||||
expect(chart.saveAsSvg.calledOnce).to.equal(true)
|
||||
|
||||
// Switch to pivot
|
||||
const pivotBtn = createWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
const pivotBtn = new DOMWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
await pivotBtn.trigger('click')
|
||||
|
||||
// Find pivot and spy the method
|
||||
@@ -71,12 +71,12 @@ describe('DataView.vue', () => {
|
||||
sinon.spy(chart, 'saveAsHtml')
|
||||
|
||||
// Export to html
|
||||
const htmlBtn = createWrapper(wrapper.findComponent({ name: 'htmlIcon' }).vm.$parent)
|
||||
const htmlBtn = new DOMWrapper(wrapper.findComponent({ name: 'htmlIcon' }).vm.$parent)
|
||||
await htmlBtn.trigger('click')
|
||||
expect(chart.saveAsHtml.calledOnce).to.equal(true)
|
||||
|
||||
// Switch to pivot
|
||||
const pivotBtn = createWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
const pivotBtn = new DOMWrapper(wrapper.findComponent({ name: 'pivotIcon' }).vm.$parent)
|
||||
await pivotBtn.trigger('click')
|
||||
|
||||
// Find pivot and spy the method
|
||||
@@ -94,7 +94,7 @@ describe('DataView.vue', () => {
|
||||
sinon.spy(window, 'alert')
|
||||
const wrapper = mount(DataView)
|
||||
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
expect(
|
||||
@@ -117,7 +117,7 @@ describe('DataView.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// The dialog is shown...
|
||||
@@ -156,7 +156,7 @@ describe('DataView.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// Switch to microtasks (let prepareCopy run)
|
||||
@@ -181,7 +181,7 @@ describe('DataView.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// Switch to microtasks (let prepareCopy run)
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('Pivot.vue', () => {
|
||||
|
||||
it('renders pivot table', () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -39,25 +39,25 @@ describe('Pivot.vue', () => {
|
||||
}
|
||||
})
|
||||
const colLabels = wrapper.findAll('.pivot-output thead th.pvtColLabel')
|
||||
expect(colLabels.at(0).text()).to.equal('2020')
|
||||
expect(colLabels.at(1).text()).to.equal('2021')
|
||||
expect(colLabels[0].text()).to.equal('2020')
|
||||
expect(colLabels[1].text()).to.equal('2021')
|
||||
const rows = wrapper.findAll('.pivot-output tbody tr')
|
||||
// row0: bar - 2 - 1
|
||||
expect(rows.at(0).find('th').text()).to.equal('bar')
|
||||
expect(rows.at(0).find('td.col0').text()).to.equal('2')
|
||||
expect(rows.at(0).find('td.col1').text()).to.equal('1')
|
||||
expect(rows.at(0).find('td.rowTotal').text()).to.equal('3')
|
||||
expect(rows[0].find('th').text()).to.equal('bar')
|
||||
expect(rows[0].find('td.col0').text()).to.equal('2')
|
||||
expect(rows[0].find('td.col1').text()).to.equal('1')
|
||||
expect(rows[0].find('td.rowTotal').text()).to.equal('3')
|
||||
|
||||
// row1: foo - - 2
|
||||
expect(rows.at(1).find('th').text()).to.equal('foo')
|
||||
expect(rows.at(1).find('td.col0').text()).to.equal('')
|
||||
expect(rows.at(1).find('td.col1').text()).to.equal('1')
|
||||
expect(rows.at(1).find('td.rowTotal').text()).to.equal('1')
|
||||
expect(rows[1].find('th').text()).to.equal('foo')
|
||||
expect(rows[1].find('td.col0').text()).to.equal('')
|
||||
expect(rows[1].find('td.col1').text()).to.equal('1')
|
||||
expect(rows[1].find('td.rowTotal').text()).to.equal('1')
|
||||
})
|
||||
|
||||
it('updates when dataSource changes', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -82,31 +82,31 @@ describe('Pivot.vue', () => {
|
||||
})
|
||||
|
||||
const colLabels = wrapper.findAll('.pivot-output thead th.pvtColLabel')
|
||||
expect(colLabels.at(0).text()).to.equal('2020')
|
||||
expect(colLabels.at(1).text()).to.equal('2021')
|
||||
expect(colLabels[0].text()).to.equal('2020')
|
||||
expect(colLabels[1].text()).to.equal('2021')
|
||||
const rows = wrapper.findAll('.pivot-output tbody tr')
|
||||
// row0: bar - 2 - 1
|
||||
expect(rows.at(0).find('th').text()).to.equal('bar')
|
||||
expect(rows.at(0).find('td.col0').text()).to.equal('2')
|
||||
expect(rows.at(0).find('td.col1').text()).to.equal('1')
|
||||
expect(rows.at(0).find('td.rowTotal').text()).to.equal('3')
|
||||
expect(rows[0].find('th').text()).to.equal('bar')
|
||||
expect(rows[0].find('td.col0').text()).to.equal('2')
|
||||
expect(rows[0].find('td.col1').text()).to.equal('1')
|
||||
expect(rows[0].find('td.rowTotal').text()).to.equal('3')
|
||||
|
||||
// row1: baz - 1 -
|
||||
expect(rows.at(1).find('th').text()).to.equal('baz')
|
||||
expect(rows.at(1).find('td.col0').text()).to.equal('1')
|
||||
expect(rows.at(1).find('td.col1').text()).to.equal('')
|
||||
expect(rows.at(1).find('td.rowTotal').text()).to.equal('1')
|
||||
expect(rows[1].find('th').text()).to.equal('baz')
|
||||
expect(rows[1].find('td.col0').text()).to.equal('1')
|
||||
expect(rows[1].find('td.col1').text()).to.equal('')
|
||||
expect(rows[1].find('td.rowTotal').text()).to.equal('1')
|
||||
|
||||
// row2: foo - - 2
|
||||
expect(rows.at(2).find('th').text()).to.equal('foo')
|
||||
expect(rows.at(2).find('td.col0').text()).to.equal('')
|
||||
expect(rows.at(2).find('td.col1').text()).to.equal('2')
|
||||
expect(rows.at(2).find('td.rowTotal').text()).to.equal('2')
|
||||
expect(rows[2].find('th').text()).to.equal('foo')
|
||||
expect(rows[2].find('td.col0').text()).to.equal('')
|
||||
expect(rows[2].find('td.col1').text()).to.equal('2')
|
||||
expect(rows[2].find('td.rowTotal').text()).to.equal('2')
|
||||
})
|
||||
|
||||
it('returns options for save', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -182,7 +182,7 @@ describe('Pivot.vue', () => {
|
||||
|
||||
it('prepareCopy returns canvas for tables and url for plotly charts', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -239,7 +239,7 @@ describe('Pivot.vue', () => {
|
||||
|
||||
it('saveAsSvg calls chart method if renderer is Custom Chart', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -274,7 +274,7 @@ describe('Pivot.vue', () => {
|
||||
|
||||
it('saveAsHtml calls chart method if renderer is Custom Chart', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -309,7 +309,7 @@ describe('Pivot.vue', () => {
|
||||
|
||||
it('saveAsPng calls chart method if renderer is Custom Chart', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -346,7 +346,7 @@ describe('Pivot.vue', () => {
|
||||
sinon.spy(chartHelper, 'getImageDataUrl')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -374,7 +374,7 @@ describe('Pivot.vue', () => {
|
||||
sinon.spy(chartHelper, 'getHtml')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -404,7 +404,7 @@ describe('Pivot.vue', () => {
|
||||
sinon.stub(fIo, 'exportToFile')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -434,7 +434,7 @@ describe('Pivot.vue', () => {
|
||||
sinon.stub(fIo, 'downloadFromUrl')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
@@ -466,7 +466,7 @@ describe('Pivot.vue', () => {
|
||||
sinon.stub(fIo, 'downloadFromUrl')
|
||||
|
||||
const wrapper = mount(Pivot, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
|
||||
@@ -4,7 +4,7 @@ import PivotSortBtn from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot/PivotUi
|
||||
|
||||
describe('PivotSortBtn.vue', () => {
|
||||
it('switches order', async () => {
|
||||
const wrapper = shallowMount(PivotSortBtn, { propsData: { value: 'key_a_to_z' } })
|
||||
const wrapper = shallowMount(PivotSortBtn, { props: { value: 'key_a_to_z' } })
|
||||
|
||||
expect(wrapper.vm.value).to.equal('key_a_to_z')
|
||||
await wrapper.find('.pivot-sort-btn').trigger('click')
|
||||
|
||||
@@ -5,13 +5,13 @@ import PivotUi from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot/PivotUi'
|
||||
describe('PivotUi.vue', () => {
|
||||
it('returns value when settings changed', async () => {
|
||||
const wrapper = mount(PivotUi, {
|
||||
propsData: {
|
||||
props: {
|
||||
keyNames: ['foo', 'bar']
|
||||
}
|
||||
})
|
||||
|
||||
// choose columns
|
||||
await wrapper.findAll('.sqliteviz-select.cols .multiselect__element > span').at(0)
|
||||
await wrapper.findAll('.sqliteviz-select.cols .multiselect__element > span')[0]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(1)
|
||||
@@ -25,7 +25,7 @@ describe('PivotUi.vue', () => {
|
||||
expect(wrapper.emitted().input[0][0].vals).to.eql([])
|
||||
|
||||
// choose rows
|
||||
await wrapper.findAll('.sqliteviz-select.rows .multiselect__element > span').at(0)
|
||||
await wrapper.findAll('.sqliteviz-select.rows .multiselect__element > span')[0]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(2)
|
||||
@@ -65,7 +65,7 @@ describe('PivotUi.vue', () => {
|
||||
expect(wrapper.emitted().input[3][0].vals).to.eql([])
|
||||
|
||||
// change aggregator
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span').at(12)
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[12]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(5)
|
||||
@@ -80,8 +80,8 @@ describe('PivotUi.vue', () => {
|
||||
|
||||
// set first aggregator argument
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.aggr-arg').at(0)
|
||||
.findAll('.multiselect__element > span').at(0)
|
||||
.findAll('.sqliteviz-select.aggr-arg')[0]
|
||||
.findAll('.multiselect__element > span')[0]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(6)
|
||||
@@ -96,8 +96,8 @@ describe('PivotUi.vue', () => {
|
||||
|
||||
// set second aggregator argument
|
||||
await wrapper
|
||||
.findAll('.sqliteviz-select.aggr-arg').at(1)
|
||||
.findAll('.multiselect__element > span').at(1)
|
||||
.findAll('.sqliteviz-select.aggr-arg')[1]
|
||||
.findAll('.multiselect__element > span')[1]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(7)
|
||||
@@ -111,7 +111,7 @@ describe('PivotUi.vue', () => {
|
||||
expect(wrapper.emitted().input[6][0].vals).to.eql(['foo', 'bar'])
|
||||
|
||||
// change renderer
|
||||
await wrapper.findAll('.sqliteviz-select.renderer .multiselect__element > span').at(13)
|
||||
await wrapper.findAll('.sqliteviz-select.renderer .multiselect__element > span')[13]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(8)
|
||||
@@ -126,7 +126,7 @@ describe('PivotUi.vue', () => {
|
||||
expect(wrapper.emitted().input[7][0].vals).to.eql(['foo', 'bar'])
|
||||
|
||||
// change aggregator again
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span').at(3)
|
||||
await wrapper.findAll('.sqliteviz-select.aggregator .multiselect__element > span')[3]
|
||||
.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().update.length).to.equal(9)
|
||||
|
||||
@@ -5,7 +5,7 @@ import Record from '@/views/Main/Workspace/Tabs/Tab/RunResult/Record'
|
||||
describe('Record.vue', () => {
|
||||
it('shows record with selected cell', async () => {
|
||||
const wrapper = mount(Record, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSet: {
|
||||
columns: ['id', 'name'],
|
||||
values: {
|
||||
@@ -20,10 +20,10 @@ describe('Record.vue', () => {
|
||||
|
||||
const rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(2)
|
||||
expect(rows.at(0).findAll('th').at(0).text()).to.equals('id')
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('2')
|
||||
expect(rows.at(1).findAll('th').at(0).text()).to.equals('name')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('bar')
|
||||
expect(rows[0].findAll('th')[0].text()).to.equals('id')
|
||||
expect(rows[0].findAll('td')[0].text()).to.equals('2')
|
||||
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"]')
|
||||
@@ -32,7 +32,7 @@ describe('Record.vue', () => {
|
||||
|
||||
it('switches to the next or previous row', async () => {
|
||||
const wrapper = mount(Record, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSet: {
|
||||
columns: ['id', 'name'],
|
||||
values: {
|
||||
@@ -47,8 +47,8 @@ describe('Record.vue', () => {
|
||||
|
||||
let rows = wrapper.findAll('tbody tr')
|
||||
expect(rows).to.have.lengthOf(2)
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('1')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('foo')
|
||||
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"]')
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
@@ -56,8 +56,8 @@ describe('Record.vue', () => {
|
||||
await wrapper.find('.next').trigger('click')
|
||||
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('2')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('bar')
|
||||
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"]')
|
||||
expect(selectedCell.text()).to.equals('2')
|
||||
@@ -65,8 +65,8 @@ describe('Record.vue', () => {
|
||||
await wrapper.find('.prev').trigger('click')
|
||||
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('1')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('foo')
|
||||
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"]')
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
@@ -74,8 +74,8 @@ describe('Record.vue', () => {
|
||||
await wrapper.find('.last').trigger('click')
|
||||
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('3')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('baz')
|
||||
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"]')
|
||||
expect(selectedCell.text()).to.equals('3')
|
||||
@@ -83,8 +83,8 @@ describe('Record.vue', () => {
|
||||
await wrapper.find('.first').trigger('click')
|
||||
|
||||
rows = wrapper.findAll('tbody tr')
|
||||
expect(rows.at(0).findAll('td').at(0).text()).to.equals('1')
|
||||
expect(rows.at(1).findAll('td').at(0).text()).to.equals('foo')
|
||||
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"]')
|
||||
expect(selectedCell.text()).to.equals('1')
|
||||
@@ -92,7 +92,7 @@ describe('Record.vue', () => {
|
||||
|
||||
it('removes selection when click on selected cell', async () => {
|
||||
const wrapper = mount(Record, {
|
||||
propsData: {
|
||||
props: {
|
||||
dataSet: {
|
||||
columns: ['id', 'name'],
|
||||
values: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect } from 'chai'
|
||||
import { mount, createWrapper } from '@vue/test-utils'
|
||||
import { mount, DOMWrapper } from '@vue/test-utils'
|
||||
import RunResult from '@/views/Main/Workspace/Tabs/Tab/RunResult'
|
||||
import csv from '@/lib/csv'
|
||||
import sinon from 'sinon'
|
||||
@@ -14,7 +14,7 @@ describe('RunResult.vue', () => {
|
||||
delete window.ClipboardItem
|
||||
sinon.spy(window, 'alert')
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -26,7 +26,7 @@ describe('RunResult.vue', () => {
|
||||
}
|
||||
})
|
||||
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
expect(
|
||||
@@ -44,7 +44,7 @@ describe('RunResult.vue', () => {
|
||||
sinon.stub(window.navigator.clipboard, 'writeText').resolves()
|
||||
const clock = sinon.useFakeTimers()
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -60,7 +60,7 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// The dialog is shown...
|
||||
@@ -90,7 +90,7 @@ describe('RunResult.vue', () => {
|
||||
sinon.stub(window.navigator.clipboard, 'writeText').resolves()
|
||||
const clock = sinon.useFakeTimers()
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -107,7 +107,7 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// Switch to microtasks (let serialize run)
|
||||
@@ -124,7 +124,7 @@ describe('RunResult.vue', () => {
|
||||
sinon.stub(window.navigator.clipboard, 'writeText').resolves()
|
||||
const clock = sinon.useFakeTimers()
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -141,7 +141,7 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Click copy to clipboard
|
||||
const copyBtn = createWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
const copyBtn = new DOMWrapper(wrapper.findComponent({ name: 'clipboardIcon' }).vm.$parent)
|
||||
await copyBtn.trigger('click')
|
||||
|
||||
// Switch to microtasks (let serialize run)
|
||||
@@ -159,7 +159,7 @@ describe('RunResult.vue', () => {
|
||||
|
||||
it('shows value of selected cell - result set', async () => {
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -172,7 +172,7 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Open cell value panel
|
||||
const viewValueBtn = createWrapper(
|
||||
const viewValueBtn = new DOMWrapper(
|
||||
wrapper.findComponent({ name: 'viewCellValueIcon' }).vm.$parent
|
||||
)
|
||||
await viewValueBtn.trigger('click')
|
||||
@@ -186,7 +186,7 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// Click on '1' cell
|
||||
const rows = wrapper.findAll('table tbody tr')
|
||||
await rows.at(0).findAll('td').at(0).trigger('click')
|
||||
await rows[0].findAll('td')[0].trigger('click')
|
||||
|
||||
expect(wrapper.find('.value-body').text()).to.equals('1')
|
||||
|
||||
@@ -207,12 +207,12 @@ describe('RunResult.vue', () => {
|
||||
expect(wrapper.find('.value-body').text()).to.equals('1')
|
||||
|
||||
// Click on 'bar' cell
|
||||
await rows.at(1).findAll('td').at(1).trigger('click')
|
||||
await rows[1].findAll('td')[1].trigger('click')
|
||||
|
||||
expect(wrapper.find('.value-body').text()).to.equals('bar')
|
||||
|
||||
// Click on 'bar' cell again
|
||||
await rows.at(1).findAll('td').at(1).trigger('click')
|
||||
await rows[1].findAll('td')[1].trigger('click')
|
||||
|
||||
expect(wrapper.find('.value-viewer-container .table-preview').text())
|
||||
.to.equals('No cell selected to view')
|
||||
@@ -220,7 +220,7 @@ describe('RunResult.vue', () => {
|
||||
|
||||
it('shows value of selected cell - record view', async () => {
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -233,13 +233,13 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Open cell value panel
|
||||
const viewValueBtn = createWrapper(
|
||||
const viewValueBtn = new DOMWrapper(
|
||||
wrapper.findComponent({ name: 'viewCellValueIcon' }).vm.$parent
|
||||
)
|
||||
await viewValueBtn.trigger('click')
|
||||
|
||||
// Go to record view
|
||||
const vierRecordBtn = createWrapper(
|
||||
const vierRecordBtn = new DOMWrapper(
|
||||
wrapper.findComponent({ name: 'rowIcon' }).vm.$parent
|
||||
)
|
||||
await vierRecordBtn.trigger('click')
|
||||
@@ -280,18 +280,18 @@ describe('RunResult.vue', () => {
|
||||
|
||||
// Click on 'foo' cell
|
||||
const rows = wrapper.findAll('table tbody tr')
|
||||
await rows.at(1).find('td').trigger('click')
|
||||
await rows[1].find('td').trigger('click')
|
||||
expect(wrapper.find('.value-body').text()).to.equals('foo')
|
||||
|
||||
// Click on 'foo' cell again
|
||||
await rows.at(1).find('td').trigger('click')
|
||||
await rows[1].find('td').trigger('click')
|
||||
expect(wrapper.find('.value-viewer-container .table-preview').text())
|
||||
.to.equals('No cell selected to view')
|
||||
})
|
||||
|
||||
it('keeps selected cell when switch between record and regular view', async () => {
|
||||
const wrapper = mount(RunResult, {
|
||||
propsData: {
|
||||
props: {
|
||||
tab: { id: 1 },
|
||||
result: {
|
||||
columns: ['id', 'name'],
|
||||
@@ -304,19 +304,19 @@ describe('RunResult.vue', () => {
|
||||
})
|
||||
|
||||
// Open cell value panel
|
||||
const viewValueBtn = createWrapper(
|
||||
const viewValueBtn = new DOMWrapper(
|
||||
wrapper.findComponent({ name: 'viewCellValueIcon' }).vm.$parent
|
||||
)
|
||||
await viewValueBtn.trigger('click')
|
||||
|
||||
// Click on 'name-1' cell
|
||||
const rows = wrapper.findAll('table tbody tr')
|
||||
await rows.at(1).findAll('td').at(1).trigger('click')
|
||||
await rows[1].findAll('td')[1].trigger('click')
|
||||
|
||||
expect(wrapper.find('.value-body').text()).to.equals('name-1')
|
||||
|
||||
// Go to record view
|
||||
const vierRecordBtn = createWrapper(
|
||||
const vierRecordBtn = new DOMWrapper(
|
||||
wrapper.findComponent({ name: 'rowIcon' }).vm.$parent
|
||||
)
|
||||
await vierRecordBtn.trigger('click')
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('ValueViewer.vue', () => {
|
||||
|
||||
it('shows value in text mode', async () => {
|
||||
const wrapper = mount(ValueViewer, {
|
||||
propsData: {
|
||||
props: {
|
||||
cellValue: 'foo'
|
||||
}
|
||||
})
|
||||
@@ -20,7 +20,7 @@ describe('ValueViewer.vue', () => {
|
||||
|
||||
it('shows error in json mode if the value is not json', async () => {
|
||||
const wrapper = mount(ValueViewer, {
|
||||
propsData: {
|
||||
props: {
|
||||
cellValue: 'foo'
|
||||
}
|
||||
})
|
||||
@@ -31,7 +31,7 @@ describe('ValueViewer.vue', () => {
|
||||
it('copy to clipboard', async () => {
|
||||
sinon.stub(window.navigator.clipboard, 'writeText').resolves()
|
||||
const wrapper = mount(ValueViewer, {
|
||||
propsData: {
|
||||
props: {
|
||||
cellValue: 'foo'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('SqlEditor.vue', () => {
|
||||
}
|
||||
const store = new Vuex.Store({ state })
|
||||
|
||||
const wrapper = mount(SqlEditor, { store, propsData: { isGettingResults: false } })
|
||||
const wrapper = mount(SqlEditor, { store, props: { isGettingResults: false } })
|
||||
await wrapper.findComponent({ name: 'codemirror' }).vm.$emit('input', 'SELECT * FROM foo')
|
||||
const runButton = wrapper.findComponent({ name: 'RunIcon' }).vm.$parent
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { mount, createWrapper } from '@vue/test-utils'
|
||||
import { mount, DOMWrapper } from '@vue/test-utils'
|
||||
import mutations from '@/store/mutations'
|
||||
import Vuex from 'vuex'
|
||||
import Tab from '@/views/Main/Workspace/Tabs/Tab'
|
||||
@@ -29,8 +29,10 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab: {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -68,8 +70,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab: {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -103,8 +107,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab: {
|
||||
id: 1,
|
||||
name: 'foo',
|
||||
@@ -159,8 +165,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab: state.tabs[0]
|
||||
}
|
||||
})
|
||||
@@ -199,8 +207,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab: state.tabs[0]
|
||||
}
|
||||
})
|
||||
@@ -236,8 +246,10 @@ describe('Tab.vue', () => {
|
||||
}
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
@@ -275,8 +287,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
@@ -329,8 +343,10 @@ describe('Tab.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tab, {
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
@@ -372,34 +388,36 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
|
||||
let tableBtn = createWrapper(wrapper.find('.above .side-tool-bar')
|
||||
let tableBtn = new DOMWrapper(wrapper.find('.above .side-tool-bar')
|
||||
.findComponent({ name: 'tableIcon' }).vm.$parent)
|
||||
await tableBtn.trigger('click')
|
||||
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.above .run-result-panel').exists()).to.equal(true)
|
||||
|
||||
const dataViewBtn = createWrapper(wrapper.find('.above .side-tool-bar')
|
||||
const dataViewBtn = new DOMWrapper(wrapper.find('.above .side-tool-bar')
|
||||
.findComponent({ name: 'dataViewIcon' }).vm.$parent)
|
||||
await dataViewBtn.trigger('click')
|
||||
|
||||
expect(wrapper.find('.bottomPane .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.above .data-view-panel').exists()).to.equal(true)
|
||||
|
||||
const sqlEditorBtn = createWrapper(wrapper.find('.above .side-tool-bar')
|
||||
const sqlEditorBtn = new DOMWrapper(wrapper.find('.above .side-tool-bar')
|
||||
.findComponent({ name: 'sqlEditorIcon' }).vm.$parent)
|
||||
await sqlEditorBtn.trigger('click')
|
||||
|
||||
expect(wrapper.find('.above .sql-editor-panel').exists()).to.equal(true)
|
||||
expect(wrapper.find('.bottomPane .data-view-panel').exists()).to.equal(true)
|
||||
|
||||
tableBtn = createWrapper(wrapper.find('.bottomPane .side-tool-bar')
|
||||
tableBtn = new DOMWrapper(wrapper.find('.bottomPane .side-tool-bar')
|
||||
.findComponent({ name: 'tableIcon' }).vm.$parent)
|
||||
await tableBtn.trigger('click')
|
||||
|
||||
@@ -435,8 +453,10 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
@@ -473,8 +493,10 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
@@ -510,8 +532,10 @@ describe('Tab.vue', () => {
|
||||
const wrapper = mount(Tab, {
|
||||
attachTo: place,
|
||||
store,
|
||||
stubs: ['chart'],
|
||||
propsData: {
|
||||
global: {
|
||||
stubs: ['chart']
|
||||
},
|
||||
props: {
|
||||
tab
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { shallowMount, mount, createWrapper } from '@vue/test-utils'
|
||||
import { shallowMount, mount, DOMWrapper } from '@vue/test-utils'
|
||||
import mutations from '@/store/mutations'
|
||||
import Vuex from 'vuex'
|
||||
import Tabs from '@/views/Main/Workspace/Tabs'
|
||||
@@ -20,7 +20,9 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// check start-guide visibility
|
||||
@@ -41,7 +43,9 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// check start-guide visibility
|
||||
@@ -50,12 +54,12 @@ describe('Tabs.vue', () => {
|
||||
// check tabs
|
||||
expect(wrapper.findAllComponents({ name: 'Tab' })).to.have.lengthOf(2)
|
||||
|
||||
const firstTab = wrapper.findAll('.tab').at(0)
|
||||
const firstTab = wrapper.findAll('.tab')[0]
|
||||
expect(firstTab.text()).to.include('foo')
|
||||
expect(firstTab.find('.star').isVisible()).to.equal(false)
|
||||
expect(firstTab.classes()).to.not.include('tab-selected')
|
||||
|
||||
const secondTab = wrapper.findAll('.tab').at(1)
|
||||
const secondTab = wrapper.findAll('.tab')[1]
|
||||
expect(secondTab.text()).to.include('Untitled')
|
||||
expect(secondTab.find('.star').isVisible()).to.equal(true)
|
||||
expect(secondTab.classes()).to.include('tab-selected')
|
||||
@@ -76,16 +80,18 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// click on the first tab
|
||||
const firstTab = wrapper.findAll('.tab').at(0)
|
||||
const firstTab = wrapper.findAll('.tab')[0]
|
||||
await firstTab.trigger('click')
|
||||
|
||||
// check that first tab is the current now
|
||||
expect(firstTab.classes()).to.include('tab-selected')
|
||||
const secondTab = wrapper.findAll('.tab').at(1)
|
||||
const secondTab = wrapper.findAll('.tab')[1]
|
||||
expect(secondTab.classes()).to.not.include('tab-selected')
|
||||
expect(state.currentTabId).to.equal(1)
|
||||
})
|
||||
@@ -130,17 +136,19 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// click on the close icon of the first tab
|
||||
const firstTabCloseIcon = wrapper.findAll('.tab').at(0).find('.close-icon')
|
||||
const firstTabCloseIcon = wrapper.findAll('.tab')[0].find('.close-icon')
|
||||
await firstTabCloseIcon.trigger('click')
|
||||
|
||||
// check that the only one tab left and it's opened
|
||||
expect(wrapper.findAllComponents({ name: 'Tab' })).to.have.lengthOf(1)
|
||||
|
||||
const firstTab = wrapper.findAll('.tab').at(0)
|
||||
const firstTab = wrapper.findAll('.tab')[0]
|
||||
expect(firstTab.text()).to.include('Untitled')
|
||||
expect(firstTab.find('.star').isVisible()).to.equal(true)
|
||||
expect(firstTab.classes()).to.include('tab-selected')
|
||||
@@ -186,11 +194,13 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// click on the close icon of the second tab
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab').at(1).find('.close-icon')
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab')[1].find('.close-icon')
|
||||
await secondTabCloseIcon.trigger('click')
|
||||
|
||||
// check that Close Tab dialog is visible
|
||||
@@ -252,11 +262,13 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// click on the close icon of the second tab
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab').at(1).find('.close-icon')
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab')[1].find('.close-icon')
|
||||
await secondTabCloseIcon.trigger('click')
|
||||
|
||||
// find 'Close without saving' in the dialog
|
||||
@@ -269,13 +281,13 @@ describe('Tabs.vue', () => {
|
||||
|
||||
// check that tab is closed
|
||||
expect(wrapper.findAllComponents({ name: 'Tab' })).to.have.lengthOf(1)
|
||||
const firstTab = wrapper.findAll('.tab').at(0)
|
||||
const firstTab = wrapper.findAll('.tab')[0]
|
||||
expect(firstTab.text()).to.include('foo')
|
||||
expect(firstTab.find('.star').isVisible()).to.equal(false)
|
||||
expect(firstTab.classes()).to.include('tab-selected')
|
||||
|
||||
// check that 'saveInquiry' event was not emited
|
||||
const rootWrapper = createWrapper(wrapper.vm.$root)
|
||||
const rootWrapper = new DOMWrapper(wrapper.vm.$root)
|
||||
expect(rootWrapper.emitted('saveInquiry')).to.equal(undefined)
|
||||
|
||||
// check that the dialog is closed
|
||||
@@ -322,11 +334,13 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
// click on the close icon of the second tab
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab').at(1).find('.close-icon')
|
||||
const secondTabCloseIcon = wrapper.findAll('.tab')[1].find('.close-icon')
|
||||
await secondTabCloseIcon.trigger('click')
|
||||
|
||||
// find 'Save and close' in the dialog
|
||||
@@ -342,13 +356,13 @@ describe('Tabs.vue', () => {
|
||||
|
||||
// check that tab is closed
|
||||
expect(wrapper.findAllComponents({ name: 'Tab' })).to.have.lengthOf(1)
|
||||
const firstTab = wrapper.findAll('.tab').at(0)
|
||||
const firstTab = wrapper.findAll('.tab')[0]
|
||||
expect(firstTab.text()).to.include('foo')
|
||||
expect(firstTab.find('.star').isVisible()).to.equal(false)
|
||||
expect(firstTab.classes()).to.include('tab-selected')
|
||||
|
||||
// check that 'saveInquiry' event was emited
|
||||
const rootWrapper = createWrapper(wrapper.vm.$root)
|
||||
const rootWrapper = new DOMWrapper(wrapper.vm.$root)
|
||||
expect(rootWrapper.emitted('saveInquiry')).to.have.lengthOf(1)
|
||||
|
||||
// check that the dialog is closed
|
||||
@@ -370,7 +384,9 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
const event = new Event('beforeunload')
|
||||
@@ -394,7 +410,9 @@ describe('Tabs.vue', () => {
|
||||
// mount the component
|
||||
const wrapper = shallowMount(Tabs, {
|
||||
store,
|
||||
stubs: ['router-link']
|
||||
global: {
|
||||
stubs: ['router-link']
|
||||
}
|
||||
})
|
||||
|
||||
const event = new Event('beforeunload')
|
||||
|
||||
Reference in New Issue
Block a user