File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ describe('pie', () => {
20
20
} ) ;
21
21
22
22
pie . render ( ) ;
23
+ expect ( pie . type ) . toBe ( 'pie' ) ;
24
+ // @ts -ignore
25
+ expect ( pie . getDefaultOptions ( ) ) . toBe ( Pie . getDefaultOptions ( ) ) ;
23
26
24
27
const geometry = pie . chart . geometries [ 0 ] ;
25
28
const elements = geometry . elements ;
Original file line number Diff line number Diff line change 1
1
import { Chart } from '@antv/g2' ;
2
2
import { Pie , PieOptions } from '../../../../src' ;
3
+ import { DEFAULT_OPTIONS } from '../../../../src/plots/pie/contants' ;
3
4
import { POSITIVE_NEGATIVE_DATA } from '../../../data/common' ;
4
5
import { delay } from '../../../utils/delay' ;
5
6
import { createDiv } from '../../../utils/dom' ;
@@ -301,6 +302,22 @@ describe('中心文本 - 指标卡', () => {
301
302
expect ( htmlAnnotations [ 0 ] . getBoundingClientRect ( ) . width ) . toEqual ( 600 ) ;
302
303
} ) ;
303
304
305
+ it ( 'statistic 默认继承 defaultOptions' , ( ) => {
306
+ pie . update ( { statistic : null } ) ;
307
+ expect ( pie . chart . ele . querySelectorAll ( '.g2-html-annotation' ) . length ) . toBe ( 0 ) ;
308
+
309
+ pie . update ( { statistic : { } } ) ;
310
+ expect ( pie . chart . ele . querySelectorAll ( '.g2-html-annotation' ) . length ) . toBe ( 2 ) ;
311
+ expect ( pie . options . statistic ) . toEqual ( { } ) ;
312
+ setTimeout ( ( ) => {
313
+ // @ts -ignore
314
+ const annotations = pie . chart . ele . querySelectorAll ( '.g2-html-annotation' ) as HTMLDivElement [ ] ;
315
+ expect ( annotations [ 0 ] . style . fontSize ) . toEqual ( DEFAULT_OPTIONS . statistic . title . fontSize ) ;
316
+ expect ( annotations [ 1 ] . style . color ) . toEqual ( DEFAULT_OPTIONS . statistic . content . color ) ;
317
+ expect ( annotations [ 1 ] . style ) . toMatchObject ( DEFAULT_OPTIONS . statistic . content ) ;
318
+ } , 0 ) ;
319
+ } ) ;
320
+
304
321
afterEach ( ( ) => {
305
322
pie . chart . clear ( ) ;
306
323
} ) ;
You can’t perform that action at this time.
0 commit comments