1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

fix JS error during running queries #80

This commit is contained in:
lana-k
2021-08-18 21:50:42 +02:00
parent 679a785d70
commit cabc4f8acd
2 changed files with 20 additions and 2 deletions

View File

@@ -66,8 +66,10 @@ export default {
dataSources () { dataSources () {
// we need to update state.data in order to update the graph // we need to update state.data in order to update the graph
// https://github.com/plotly/react-chart-editor/issues/948 // https://github.com/plotly/react-chart-editor/issues/948
if (this.dataSources) {
dereference(this.state.data, this.dataSources) dereference(this.state.data, this.dataSources)
} }
}
}, },
methods: { methods: {
handleResize () { handleResize () {

View File

@@ -27,7 +27,7 @@ describe('Chart.vue', () => {
expect(wrapper.emitted('update')).to.have.lengthOf(1) expect(wrapper.emitted('update')).to.have.lengthOf(1)
}) })
it('calls dereference when sqlResult is changed', async () => { it('calls dereference when dataSources is changed', async () => {
sinon.stub(dereference, 'default') sinon.stub(dereference, 'default')
const dataSources = { const dataSources = {
id: [1], id: [1],
@@ -47,4 +47,20 @@ describe('Chart.vue', () => {
await wrapper.setProps({ dataSources: newDataSources }) await wrapper.setProps({ dataSources: newDataSources })
expect(dereference.default.called).to.equal(true) expect(dereference.default.called).to.equal(true)
}) })
it(`doesn't calls dereference when dataSources is null`, async () => {
sinon.stub(dereference, 'default')
const dataSources = {
id: [1],
name: ['foo']
}
// mount the component
const wrapper = shallowMount(Chart, {
propsData: { dataSources }
})
await wrapper.setProps({ dataSources: null })
expect(dereference.default.called).to.equal(false)
})
}) })