/
Scatter.spec.js
44 lines (35 loc) 路 1.19 KB
/
Scatter.spec.js
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
import { mount } from '@vue/test-utils'
import LegacyScatter from './examples/Scatter.vue'
describe('LegacyScatter', () => {
const Component = {
template:
'<div><LegacyScatter :chartId="chartId" :plugins="plugins" /></div>',
components: { LegacyScatter },
props: ['chartId', 'plugins']
}
it('should render a canvas', () => {
const wrapper = mount(Component)
const scatterChartEl = wrapper.find('#scatter-chart')
expect(scatterChartEl.element.id).not.toBe('undefined')
expect(scatterChartEl.exists()).toBe(true)
const canvasEl = wrapper.find('canvas')
expect(canvasEl.exists()).toBe(true)
})
it('should change id based on prop', () => {
const wrapper = mount(Component, {
propsData: { chartId: 'scatterchartprop' }
})
const scatterChartEl = wrapper.find('#scatterchartprop')
expect(scatterChartEl.element.id).not.toBe('undefined')
expect(scatterChartEl.exists()).toBe(true)
})
it('should add inline plugins based on prop', () => {
const testPlugin = {
id: 'test'
}
const wrapper = mount(Component, {
propsData: { plugins: [testPlugin] }
})
expect(wrapper.props().plugins.length).toEqual(1)
})
})