mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-02-04 15:38:55 +08:00
tests
This commit is contained in:
1206
tests/lib/graphHelper.spec.js
Normal file
1206
tests/lib/graphHelper.spec.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@ describe('Chart.vue', () => {
|
||||
})
|
||||
|
||||
it('getOptionsForSave called with proper arguments', () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Chart, {
|
||||
global: {
|
||||
mocks: { $store }
|
||||
@@ -30,7 +29,6 @@ describe('Chart.vue', () => {
|
||||
})
|
||||
|
||||
it('emits update when plotly updates', async () => {
|
||||
// mount the component
|
||||
const wrapper = mount(Chart, {
|
||||
global: {
|
||||
mocks: { $store }
|
||||
@@ -48,7 +46,6 @@ describe('Chart.vue', () => {
|
||||
points: [80]
|
||||
}
|
||||
|
||||
// mount the component
|
||||
const wrapper = mount(Chart, {
|
||||
props: {
|
||||
dataSources,
|
||||
@@ -208,4 +205,40 @@ describe('Chart.vue', () => {
|
||||
expect(wrapper.find('.Select__menu').text()).to.contain('name' + 'points')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('hides and shows controls depending on showViewSettings and resizes the plot', async () => {
|
||||
const wrapper = mount(Chart, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
dataSources: null
|
||||
},
|
||||
global: {
|
||||
mocks: { $store }
|
||||
}
|
||||
})
|
||||
|
||||
// don't call flushPromises here, otherwize resize observer will be call to often
|
||||
// which causes ResizeObserver loop completed with undelivered notifications.
|
||||
await nextTick()
|
||||
|
||||
const plot = wrapper.find('.svg-container').wrapperElement
|
||||
|
||||
const initialPlotWidth = plot.scrollWidth
|
||||
const initialPlotHeight = plot.scrollHeight
|
||||
|
||||
expect(wrapper.find('.plotly_editor .editor_controls').exists()).to.equal(
|
||||
false
|
||||
)
|
||||
|
||||
await wrapper.setProps({ showViewSettings: true })
|
||||
|
||||
await flushPromises()
|
||||
|
||||
expect(plot.scrollWidth).not.to.equal(initialPlotWidth)
|
||||
expect(plot.scrollHeight).not.to.equal(initialPlotHeight)
|
||||
expect(wrapper.find('.plotly_editor .editor_controls').exists()).to.equal(
|
||||
true
|
||||
)
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -586,4 +586,48 @@ describe('Pivot.vue', () => {
|
||||
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('hides or shows controlls depending on showViewSettings and resizes standart chart', async () => {
|
||||
const wrapper = mount(Pivot, {
|
||||
global: {
|
||||
mocks: { $store: { state: { isWorkspaceVisible: true } } }
|
||||
},
|
||||
props: {
|
||||
dataSources: {
|
||||
item: ['foo', 'bar', 'bar', 'bar'],
|
||||
year: [2021, 2021, 2020, 2020]
|
||||
},
|
||||
initOptions: {
|
||||
rows: ['item'],
|
||||
cols: ['year'],
|
||||
colOrder: 'key_a_to_z',
|
||||
rowOrder: 'key_a_to_z',
|
||||
aggregatorName: 'Count',
|
||||
vals: [],
|
||||
renderer: $.pivotUtilities.renderers['Bar Chart'],
|
||||
rendererName: 'Bar Chart'
|
||||
}
|
||||
},
|
||||
attachTo: container
|
||||
})
|
||||
|
||||
expect(wrapper.find('.pivot-ui').isVisible()).to.equal(false)
|
||||
|
||||
await flushPromises()
|
||||
|
||||
const plot = wrapper.find('.svg-container').wrapperElement
|
||||
const initialPlotHeight = plot.scrollHeight
|
||||
|
||||
await wrapper.setProps({ showViewSettings: true })
|
||||
expect(wrapper.find('.pivot-ui').isVisible()).to.equal(true)
|
||||
|
||||
await flushPromises()
|
||||
const plotAfterResize = wrapper.find('.svg-container').wrapperElement
|
||||
|
||||
expect(plotAfterResize.scrollWidth.scrollHeight).not.to.equal(
|
||||
initialPlotHeight
|
||||
)
|
||||
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user