Add tests for chart instance destroying

This commit is contained in:
Jakub Juszczak
2016-12-20 20:03:17 +01:00
parent 52c1c50206
commit 988d8f13b4
7 changed files with 145 additions and 0 deletions

View File

@@ -40,4 +40,25 @@ describe('BarChart', () => {
expect(vm.$el.querySelector('#barchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
BarChart
)
},
components: { BarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,25 @@ describe('BubbleChart', () => {
expect(vm.$el.querySelector('#bubblechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
BubbleChart
)
},
components: { BubbleChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,25 @@ describe('DoughnutChart', () => {
expect(vm.$el.querySelector('#doughnutchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
DoughnutChart
)
},
components: { DoughnutChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,25 @@ describe('LineChart', () => {
expect(vm.$el.querySelector('#linechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
LineChart
)
},
components: { LineChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,24 @@ describe('PieChart', () => {
expect(vm.$el.querySelector('#piechartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
PieChart
)
},
components: { PieChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,25 @@ describe('PolarChart', () => {
expect(vm.$el.querySelector('#polarchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
PolarChart
)
},
components: { PolarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})

View File

@@ -40,4 +40,24 @@ describe('RadarChart', () => {
expect(vm.$el.querySelector('#rodarchartprop')).not.to.be.an('undefined')
})
it('should destroy chart instance', (done) => {
const vm = new Vue({
render: function (createElement) {
return createElement(
RadarChart
)
},
components: { RadarChart }
}).$mount(el)
expect(vm.$children[0]._chart.chart.ctx).not.to.be.null
vm.$destroy()
vm.$nextTick(() => {
vm.$forceUpdate()
expect(vm.$children[0]._chart.chart.ctx).to.be.null
done()
})
})
})