@@ -2,28 +2,26 @@ import { Liquid } from '../../../../src';
2
2
import { createDiv } from '../../../utils/dom' ;
3
3
4
4
describe ( 'liquid' , ( ) => {
5
- it ( 'liquidStyle' , ( ) => {
6
- const liquid = new Liquid ( createDiv ( ) , {
7
- width : 600 ,
8
- height : 300 ,
9
- percent : 0.25 ,
10
- liquidStyle : ( { percent } ) => {
11
- return {
12
- fill : percent > 0.75 ? 'red' : 'green' ,
13
- } ;
14
- } ,
15
- color : 'blue' ,
16
- } ) ;
5
+ const liquid = new Liquid ( createDiv ( ) , {
6
+ width : 600 ,
7
+ height : 300 ,
8
+ percent : 0.25 ,
9
+ liquidStyle : ( { percent } ) => {
10
+ return {
11
+ fill : percent > 0.75 ? 'red' : 'green' ,
12
+ } ;
13
+ } ,
14
+ color : 'blue' ,
15
+ } ) ;
17
16
18
- const getBorderColor = ( liquid ) => liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 2 ] . attr ( 'stroke' ) ;
19
- const getWaveColor = ( liquid ) =>
20
- liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'fill' ) ;
17
+ const getBorderColor = ( liquid ) => liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 2 ] . attr ( 'stroke' ) ;
18
+ const getWaveColor = ( liquid ) =>
19
+ liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'fill' ) ;
21
20
21
+ it ( 'liquidStyle' , ( ) => {
22
22
liquid . render ( ) ;
23
23
24
- // @ts -ignore
25
24
expect ( getBorderColor ( liquid ) ) . toBe ( 'blue' ) ; // circle
26
- // @ts -ignore
27
25
expect ( getWaveColor ( liquid ) ) . toBe ( 'green' ) ; // wave path
28
26
29
27
// @ts -ignore
@@ -36,10 +34,26 @@ describe('liquid', () => {
36
34
percent : 0.8 ,
37
35
} ) ;
38
36
39
- // G2 chart.clear 的时候,geometry 销毁了,但是 container 还保留的,内存泄露。
40
37
// @ts -ignore
41
38
expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'fill' ) ) . toBe ( 'red' ) ; // wave path
39
+ } ) ;
40
+
41
+ it ( 'outline style' , ( ) => {
42
+ liquid . update ( {
43
+ color : 'pink' ,
44
+ } ) ;
45
+
46
+ expect ( getBorderColor ( liquid ) ) . toBe ( 'pink' ) ; // circle
47
+ expect ( getWaveColor ( liquid ) ) . toBe ( 'red' ) ; // wave path
48
+
49
+ liquid . update ( { outline : { style : { stroke : 'purple' , strokeOpacity : 0.2 } } , liquidStyle : undefined } ) ;
50
+ expect ( getWaveColor ( liquid ) ) . toBe ( 'pink' ) ; // wave path
51
+ expect ( getBorderColor ( liquid ) ) . toBe ( 'purple' ) ; // circle
52
+ // @ts -ignore
53
+ expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 2 ] . attr ( 'strokeOpacity' ) ) . toBe ( 0.2 ) ;
54
+ } ) ;
42
55
56
+ afterAll ( ( ) => {
43
57
liquid . destroy ( ) ;
44
58
} ) ;
45
59
} ) ;
0 commit comments