all files / test/ index.spec.js

100% Statements 14/14
100% Branches 0/0
100% Functions 5/5
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                     
import Vue from 'vue'
import VChartist from '../src/index'
 
Vue.use(VChartist)
 
describe('test vue plugin', () => {
  let el
  before(function () {
    el = document.createElement('div')
    el.id = 'app'
    document.body.appendChild(el)
  })
 
  after(function () {
    el.parentElement.removeChild(el)
  })
  it('should render correct contents', done => {
    const vm = new Vue({
      el,
      replace: false,
      template: `<chartist
        type="Line"
        :data="chartData"
        :options="chartOptions">
      </chartist>`,
      data: {
        chartData: {
          labels: ['A', 'B', 'C'],
          series: [
            [1, 3, 2],
            [4, 6, 5]
          ]
        },
        chartOptions: {
          lineSmooth: false,
          width: '600px',
          height: '300px'
        }
      }
    })
 
    setTimeout(function () {
      const svg = document.getElementsByTagName('svg')
      expect(svg.length).to.be.equal(1)
      done()
    }, 50)
  })
})