Add tests

This commit is contained in:
Jakub Juszczak
2016-09-23 12:59:17 +02:00
parent d6c3f50ba8
commit 74cedd4ec4
9 changed files with 149 additions and 12 deletions

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

@@ -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: '<div><hello></hello></div>',
components: { Hello }
}).$mount()
expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!')
})
})

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