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:
@@ -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