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