forked from apertureless/vue-chartjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Doughnut.spec.ts
46 lines (37 loc) · 1.11 KB
/
Doughnut.spec.ts
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
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import { Doughnut } from '../src/index.js'
import * as doughnutChartConfig from '../sandboxes/doughnut/src/chartConfig.js'
describe('DoughnutChart', () => {
it('should render a canvas', () => {
const wrapper = mount(Doughnut, {
props: doughnutChartConfig as any
})
const canvas = wrapper.find('canvas')
expect(canvas.exists()).toBe(true)
expect(canvas.element.id).toBe('')
})
it('should change id based on prop', () => {
const wrapper = mount(Doughnut, {
props: {
id: 'doughnut-chart-id',
...doughnutChartConfig
} as any
})
const canvas = wrapper.find('canvas')
expect(canvas.exists()).toBe(true)
expect(canvas.element.id).toBe('doughnut-chart-id')
})
it('should add inline plugins based on prop', () => {
const testPlugin = {
id: 'test'
}
const wrapper = mount(Doughnut, {
props: {
plugins: [testPlugin],
...doughnutChartConfig
} as any
})
expect(wrapper.props().plugins.length).toEqual(1)
})
})