all files / test/ index.spec.js

100% Statements 13/13
100% Branches 0/0
100% Functions 5/5
100% Lines 13/13
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63                                                                                                   
import Vue from 'vue'
import VChartist from 'vchartist'
import vctTitle from '../src/index'
 
Vue.use(VChartist, {
  messageNoData: 'You have not enough data'
})
 
describe('test title plugin', function () {
  let el
  beforeEach(function () {
    el = document.createElement('div')
    el.id = 'app'
    document.body.appendChild(el)
  })
 
  afterEach(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: [{
            name: 'test',
            data: [1, 3, 2]
          }]
        },
        chartOptions: {
          lineSmooth: false,
          width: '100%',
          height: '300px',
          chartPadding: {
            top: 40,
            right: 400,
            bottom: 30,
            left: 30
          },
          plugins: [
            vctTitle({
              title: 'hello'
            })
          ]
        }
      }
    })
 
    setTimeout(function () {
      const legend = document.querySelectorAll('.ct-title')
      expect(legend.length).to.be.equal(1)
      done()
    }, 50)
  })
})