|
1 | 1 | import React from 'react'; |
2 | 2 | import ReactECharts from '../../src/'; |
3 | 3 | import type { EChartsOption } from '../../src/'; |
| 4 | +import type { EChartsOption as DefaultEChartsOption } from 'echarts/types/dist/shared'; |
| 5 | +import type { EChartsOption as SharedComponentEChartsOption } from 'echarts'; |
4 | 6 | import { render, destroy, createDiv, removeDom } from '../utils'; |
5 | 7 |
|
6 | 8 | const options: EChartsOption = { |
@@ -36,6 +38,68 @@ describe('chart', () => { |
36 | 38 | removeDom(div); |
37 | 39 | }); |
38 | 40 |
|
| 41 | + it('DefaultEChartsOption', () => { |
| 42 | + let instance; |
| 43 | + const div = createDiv(); |
| 44 | + const defaultOptions: DefaultEChartsOption = { |
| 45 | + xAxis: { |
| 46 | + type: 'category', |
| 47 | + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], |
| 48 | + }, |
| 49 | + yAxis: { |
| 50 | + type: 'value', |
| 51 | + }, |
| 52 | + series: [ |
| 53 | + { |
| 54 | + data: [820, 932, 901, 934, 1290, 1330, 1320], |
| 55 | + type: 'line', |
| 56 | + smooth: true, |
| 57 | + }, |
| 58 | + ], |
| 59 | + }; |
| 60 | + const Comp = <ReactECharts ref={(e) => (instance = e)} option={defaultOptions} />; |
| 61 | + render(Comp, div); |
| 62 | + |
| 63 | + expect(instance).toBeDefined(); |
| 64 | + expect(instance.getEchartsInstance()).toBeDefined(); |
| 65 | + |
| 66 | + destroy(div); |
| 67 | + expect(div.querySelector('*')).toBe(null); |
| 68 | + |
| 69 | + removeDom(div); |
| 70 | + }); |
| 71 | + |
| 72 | + it('SharedComponentEChartsOption', () => { |
| 73 | + let instance; |
| 74 | + const div = createDiv(); |
| 75 | + const sharedOptions: SharedComponentEChartsOption = { |
| 76 | + xAxis: { |
| 77 | + type: 'category', |
| 78 | + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], |
| 79 | + }, |
| 80 | + yAxis: { |
| 81 | + type: 'value', |
| 82 | + }, |
| 83 | + series: [ |
| 84 | + { |
| 85 | + data: [820, 932, 901, 934, 1290, 1330, 1320], |
| 86 | + type: 'line', |
| 87 | + smooth: true, |
| 88 | + }, |
| 89 | + ], |
| 90 | + }; |
| 91 | + const Comp = <ReactECharts ref={(e) => (instance = e)} option={sharedOptions} />; |
| 92 | + render(Comp, div); |
| 93 | + |
| 94 | + expect(instance).toBeDefined(); |
| 95 | + expect(instance.getEchartsInstance()).toBeDefined(); |
| 96 | + |
| 97 | + destroy(div); |
| 98 | + expect(div.querySelector('*')).toBe(null); |
| 99 | + |
| 100 | + removeDom(div); |
| 101 | + }); |
| 102 | + |
39 | 103 | describe('container size', () => { |
40 | 104 | it('default', () => { |
41 | 105 | let instance; |
|
0 commit comments