Add unit tests and travis.yml

This commit is contained in:
Jakub Juszczak
2016-09-08 13:21:20 +02:00
parent 377ae5e27a
commit d913e9c515
10 changed files with 156 additions and 2 deletions

5
.travis.yml Normal file
View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "6"
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@@ -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",

View 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
})
})

View 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
})
})

View 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
})
})

View 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
})
})

View 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
})
})

View 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
})
})

View 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
})
})

View 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')
})
})