mirror of
https://github.com/KevinMidboe/vue-chartjs.git
synced 2025-10-29 09:50:21 +00:00
✅ Add unit tests and travis.yml
This commit is contained in:
5
.travis.yml
Normal file
5
.travis.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "6"
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
@@ -20,8 +20,8 @@
|
||||
"build": "node build/build.js",
|
||||
"unit": "karma start test/unit/karma.conf.js --single-run",
|
||||
"e2e": "node test/e2e/runner.js",
|
||||
"test": "npm run unit && npm run e2e",
|
||||
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
|
||||
"test": "npm run unit",
|
||||
"lint": "eslint --ext .js,.vue src test/unit/specs"
|
||||
},
|
||||
"dependencies": {
|
||||
"babel-runtime": "^6.0.0",
|
||||
|
||||
17
test/unit/specs/Bar.spec.js
Normal file
17
test/unit/specs/Bar.spec.js
Normal file
@@ -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: '<bar-chart></bar-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/Bubble.spec.js
Normal file
17
test/unit/specs/Bubble.spec.js
Normal file
@@ -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: '<bubble-chart></bubble-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/Doughnut.spec.js
Normal file
17
test/unit/specs/Doughnut.spec.js
Normal file
@@ -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: '<doughnut-chart></doughnut-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/Line.spec.js
Normal file
17
test/unit/specs/Line.spec.js
Normal file
@@ -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: '<line-chart></line-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/Pie.spec.js
Normal file
17
test/unit/specs/Pie.spec.js
Normal file
@@ -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: '<pie-chart></pie-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/PolarArea.spec.js
Normal file
17
test/unit/specs/PolarArea.spec.js
Normal file
@@ -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: '<polar-chart></polar-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
17
test/unit/specs/Radar.spec.js
Normal file
17
test/unit/specs/Radar.spec.js
Normal file
@@ -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: '<radar-chart></radar-chart>',
|
||||
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
|
||||
})
|
||||
})
|
||||
30
test/unit/specs/helpers/options.spec.js
Normal file
30
test/unit/specs/helpers/options.spec.js
Normal file
@@ -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')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user