From 74cedd4ec43d7e69d955fe914b2f534ba89c2e29 Mon Sep 17 00:00:00 2001 From: Jakub Juszczak Date: Fri, 23 Sep 2016 12:59:17 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/unit/specs/Bar.spec.js | 17 ++++++++++++++ test/unit/specs/Bubble.spec.js | 17 ++++++++++++++ test/unit/specs/Doughnut.spec.js | 17 ++++++++++++++ test/unit/specs/Hello.spec.js | 12 ---------- test/unit/specs/Line.spec.js | 17 ++++++++++++++ test/unit/specs/Pie.spec.js | 17 ++++++++++++++ test/unit/specs/PolarArea.spec.js | 17 ++++++++++++++ test/unit/specs/Radar.spec.js | 17 ++++++++++++++ test/unit/specs/helpers/options.spec.js | 30 +++++++++++++++++++++++++ 9 files changed, 149 insertions(+), 12 deletions(-) create mode 100644 test/unit/specs/Bar.spec.js create mode 100644 test/unit/specs/Bubble.spec.js create mode 100644 test/unit/specs/Doughnut.spec.js delete mode 100644 test/unit/specs/Hello.spec.js create mode 100644 test/unit/specs/Line.spec.js create mode 100644 test/unit/specs/Pie.spec.js create mode 100644 test/unit/specs/PolarArea.spec.js create mode 100644 test/unit/specs/Radar.spec.js create mode 100644 test/unit/specs/helpers/options.spec.js diff --git a/test/unit/specs/Bar.spec.js b/test/unit/specs/Bar.spec.js new file mode 100644 index 0000000..733f56c --- /dev/null +++ b/test/unit/specs/Bar.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import BarChart from 'src/examples/BarExample' + +describe('BarChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { BarChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/Bubble.spec.js b/test/unit/specs/Bubble.spec.js new file mode 100644 index 0000000..e68a5c7 --- /dev/null +++ b/test/unit/specs/Bubble.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import BubbleChart from 'src/examples/BubbleExample' + +describe('BubbleChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { BubbleChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/Doughnut.spec.js b/test/unit/specs/Doughnut.spec.js new file mode 100644 index 0000000..bd38658 --- /dev/null +++ b/test/unit/specs/Doughnut.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import DoughnutChart from 'src/examples/DoughnutExample' + +describe('DoughnutChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { DoughnutChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/Hello.spec.js b/test/unit/specs/Hello.spec.js deleted file mode 100644 index 835ad99..0000000 --- a/test/unit/specs/Hello.spec.js +++ /dev/null @@ -1,12 +0,0 @@ -import Vue from 'vue' -import Hello from 'src/components/Hello' - -describe('Hello.vue', () => { - it('should render correct contents', () => { - const vm = new Vue({ - template: '
', - components: { Hello } - }).$mount() - expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!') - }) -}) diff --git a/test/unit/specs/Line.spec.js b/test/unit/specs/Line.spec.js new file mode 100644 index 0000000..fdf9b79 --- /dev/null +++ b/test/unit/specs/Line.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import LineChart from 'src/examples/LineExample' + +describe('LineChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { LineChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/Pie.spec.js b/test/unit/specs/Pie.spec.js new file mode 100644 index 0000000..f99ecbc --- /dev/null +++ b/test/unit/specs/Pie.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import PieChart from 'src/examples/PieExample' + +describe('PieChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { PieChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/PolarArea.spec.js b/test/unit/specs/PolarArea.spec.js new file mode 100644 index 0000000..25304ce --- /dev/null +++ b/test/unit/specs/PolarArea.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import PolarChart from 'src/examples/PolarAreaExample' + +describe('PolarChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { PolarChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/Radar.spec.js b/test/unit/specs/Radar.spec.js new file mode 100644 index 0000000..6060c09 --- /dev/null +++ b/test/unit/specs/Radar.spec.js @@ -0,0 +1,17 @@ +import Vue from 'vue' +import RadarChart from 'src/examples/RadarExample' + +describe('RadarChart', () => { + it('should render a canvas', () => { + const vm = new Vue({ + el: 'body', + replace: false, + template: '', + components: { RadarChart } + }) + 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 + }) +}) diff --git a/test/unit/specs/helpers/options.spec.js b/test/unit/specs/helpers/options.spec.js new file mode 100644 index 0000000..d05ad75 --- /dev/null +++ b/test/unit/specs/helpers/options.spec.js @@ -0,0 +1,30 @@ +import { mergeOptions } from 'src/helpers/options' + +describe('mergeOptions.js', () => { + const a = { + a: 'a', + b: 'a' + } + + const b = { + a: 'b', + b: 'b' + } + + const c = { + c: 'c' + } + + it('should replace old a and b if a and b are new', () => { + let ab = mergeOptions(a, b) + expect(ab).to.have.property('a').and.to.equal('b') + expect(ab).to.have.property('b').and.to.equal('b') + }) + + it('should add c if c is new', () => { + let ac = mergeOptions(a, c) + expect(ac).to.have.property('a').and.to.equal('a') + expect(ac).to.have.property('b').and.to.equal('a') + expect(ac).to.have.property('c').and.to.equal('c') + }) +})