mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-08 02:58:54 +08:00
Pivot implementation and redesign (#69)
- Pivot support implementation - Rename queries into inquiries - Rename editor into workspace - Change result set format - New JSON format for inquiries - Redesign panels
This commit is contained in:
@@ -3,6 +3,16 @@ import { mount } from '@vue/test-utils'
|
||||
import tooltipMixin from '@/tooltipMixin'
|
||||
|
||||
describe('tooltipMixin.js', () => {
|
||||
let container
|
||||
beforeEach(() => {
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
container.remove()
|
||||
})
|
||||
|
||||
it('tooltip is hidden in initial', () => {
|
||||
const component = {
|
||||
template: '<div :style="tooltipStyle"></div>',
|
||||
@@ -12,13 +22,16 @@ describe('tooltipMixin.js', () => {
|
||||
expect(wrapper.find('div').isVisible()).to.equal(false)
|
||||
})
|
||||
|
||||
it('tooltipStyle is correct when showTooltip', async () => {
|
||||
it('tooltipStyle is correct when showTooltip: top-right', async () => {
|
||||
const component = {
|
||||
template: '<div :style="tooltipStyle"></div>',
|
||||
template: '<div :style="{...tooltipStyle, width: \'100px\'}" ref="tooltip"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component)
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseover', {
|
||||
|
||||
const wrapper = mount(component, { attachTo: container })
|
||||
|
||||
// by default top-right
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}))
|
||||
@@ -30,13 +43,73 @@ describe('tooltipMixin.js', () => {
|
||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||
})
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: top-left', async () => {
|
||||
const component = {
|
||||
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')
|
||||
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
top: '8px',
|
||||
left: '100px'
|
||||
})
|
||||
|
||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||
})
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: bottom-right', async () => {
|
||||
const component = {
|
||||
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')
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
top: '32px',
|
||||
left: '22px'
|
||||
})
|
||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||
})
|
||||
|
||||
it('tooltipStyle is correct when showTooltip: bottom-left', async () => {
|
||||
const component = {
|
||||
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')
|
||||
|
||||
expect(wrapper.vm.tooltipStyle).to.eql({
|
||||
visibility: 'visible',
|
||||
top: '32px',
|
||||
left: '100px'
|
||||
})
|
||||
expect(wrapper.find('div').isVisible()).to.equal(true)
|
||||
})
|
||||
|
||||
it('tooltip is not visible after hideTooltip', async () => {
|
||||
const component = {
|
||||
template: '<div :style="tooltipStyle"></div>',
|
||||
mixins: [tooltipMixin]
|
||||
}
|
||||
const wrapper = mount(component)
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseover', {
|
||||
await wrapper.vm.showTooltip(new MouseEvent('mouseenter', {
|
||||
clientX: 10,
|
||||
clientY: 20
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user