From 13ff782ec850af7e77c5bdaaa4755cccbe76e140 Mon Sep 17 00:00:00 2001 From: Jakub Juszczak Date: Fri, 23 Sep 2016 14:52:37 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub Juszczak --- test/unit/specs/Bar.spec.js | 20 +++++++++++++++++--- test/unit/specs/Bubble.spec.js | 20 +++++++++++++++++--- test/unit/specs/Doughnut.spec.js | 20 +++++++++++++++++--- test/unit/specs/Line.spec.js | 20 +++++++++++++++++--- test/unit/specs/Pie.spec.js | 20 +++++++++++++++++--- test/unit/specs/PolarArea.spec.js | 20 +++++++++++++++++--- test/unit/specs/Radar.spec.js | 20 +++++++++++++++++--- 7 files changed, 119 insertions(+), 21 deletions(-) diff --git a/test/unit/specs/Bar.spec.js b/test/unit/specs/Bar.spec.js index 733f56cc..b76f1083 100644 --- a/test/unit/specs/Bar.spec.js +++ b/test/unit/specs/Bar.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import BarChart from 'src/examples/BarExample' describe('BarChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { BarChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#bar-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { BarChart } + }).$mount(el) + + expect(vm.$el.querySelector('#barchartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/Bubble.spec.js b/test/unit/specs/Bubble.spec.js index e68a5c78..22b9f8a8 100644 --- a/test/unit/specs/Bubble.spec.js +++ b/test/unit/specs/Bubble.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import BubbleChart from 'src/examples/BubbleExample' describe('BubbleChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { BubbleChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#bubble-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { BubbleChart } + }).$mount(el) + + expect(vm.$el.querySelector('#bubblechartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/Doughnut.spec.js b/test/unit/specs/Doughnut.spec.js index bd386586..6da7071f 100644 --- a/test/unit/specs/Doughnut.spec.js +++ b/test/unit/specs/Doughnut.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import DoughnutChart from 'src/examples/DoughnutExample' describe('DoughnutChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { DoughnutChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#doughnut-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { DoughnutChart } + }).$mount(el) + + expect(vm.$el.querySelector('#doughnutchartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/Line.spec.js b/test/unit/specs/Line.spec.js index fdf9b79b..ce99cdf9 100644 --- a/test/unit/specs/Line.spec.js +++ b/test/unit/specs/Line.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import LineChart from 'src/examples/LineExample' describe('LineChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { LineChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#line-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { LineChart } + }).$mount(el) + + expect(vm.$el.querySelector('#linechartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/Pie.spec.js b/test/unit/specs/Pie.spec.js index f99ecbc4..097fad47 100644 --- a/test/unit/specs/Pie.spec.js +++ b/test/unit/specs/Pie.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import PieChart from 'src/examples/PieExample' describe('PieChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { PieChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#pie-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { PieChart } + }).$mount(el) + + expect(vm.$el.querySelector('#piechartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/PolarArea.spec.js b/test/unit/specs/PolarArea.spec.js index 25304ce6..921c5a92 100644 --- a/test/unit/specs/PolarArea.spec.js +++ b/test/unit/specs/PolarArea.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import PolarChart from 'src/examples/PolarAreaExample' describe('PolarChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { PolarChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#polar-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { PolarChart } + }).$mount(el) + + expect(vm.$el.querySelector('#polarchartprop')).not.to.be.an('undefined') + }) }) diff --git a/test/unit/specs/Radar.spec.js b/test/unit/specs/Radar.spec.js index 6060c094..a05a24fe 100644 --- a/test/unit/specs/Radar.spec.js +++ b/test/unit/specs/Radar.spec.js @@ -2,16 +2,30 @@ import Vue from 'vue' import RadarChart from 'src/examples/RadarExample' describe('RadarChart', () => { + let el + + beforeEach(() => { + el = document.createElement('div') + }) + it('should render a canvas', () => { const vm = new Vue({ - el: 'body', - replace: false, template: '', components: { RadarChart } - }) + }).$mount(el) + expect(vm.$el.querySelector('#radar-chart')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('undefined') expect(vm.$el.querySelector('canvas')).not.to.be.an('null') expect(vm.$el.querySelector('canvas')).to.exist }) + + it('should change id based on prop', () => { + const vm = new Vue({ + template: '', + components: { RadarChart } + }).$mount(el) + + expect(vm.$el.querySelector('#rodarchartprop')).not.to.be.an('undefined') + }) })