import { mount } from '@vue/test-utils'
import BarChart from '../../lib/components/echarts/bar/index.vue'

describe('测试柱状图是否加载成功', () => {
  const wrapper = mount(BarChart, {
    propsData: {
      width: '400px',
      height: '300px',
      title: {
        text: '数据统计'
      },
      xAxis: {
        data: ['宿迁', '盐城', '连云港', '南京市', '苏州市', '淮安市', '徐州市', '常州市', '无锡市']
      },
      yAxis: [
        {
          name: '单位:（家）',
          type: 'value'
        }
      ],
      legend: {
        left: 'center'
      },
      tooltip: {},
      series: {
        name: 'bar',
        barWidth: '40%',
        data: ['26', '27', '28', '30', '35', '31', '18', '12', '1'] }
    }
  })
  it('测试是否渲染成功', () => {
    expect(wrapper.find('canvas')).toBeTruthy()
  })

  it('测试宽度值', () => {
    expect(wrapper.find('div').attributes('style')).toContain('width: 400px')
  })

  it('测试高度值', () => {
    expect(wrapper.find('div').attributes('style')).toContain('height: 300px')
  })
})
