@@ -7,7 +7,7 @@ describe('liquid', () => {
7
7
width : 600 ,
8
8
height : 300 ,
9
9
autoFit : false ,
10
- percent : 0.75 ,
10
+ percent : 0.45 ,
11
11
} ) ;
12
12
13
13
liquid . render ( ) ;
@@ -16,16 +16,65 @@ describe('liquid', () => {
16
16
expect ( liquid . options . radius ) . toBe ( 0.9 ) ;
17
17
18
18
// @ts -ignore
19
- expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . attr ( 'r' ) ) . toBe ( 135 ) ;
19
+ expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'r' ) ) . toBe ( 135 ) ;
20
20
21
21
// 宽 < 高,按照高度来设置 radius
22
22
liquid . changeSize ( 300 , 500 ) ;
23
-
24
23
// @ts -ignore
25
- expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 1 ] . attr ( 'r' ) ) . toBe ( 135 ) ; // circle
24
+ expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'r' ) ) . toBe ( 135 ) ;
25
+ // 宽 < 高,按照高度来设置 radius
26
+ liquid . changeSize ( 500 , 500 ) ;
27
+ // @ts -ignore
28
+ expect ( liquid . chart . middleGroup . getChildren ( ) [ 0 ] . getChildren ( ) [ 0 ] . attr ( 'r' ) ) . toBe ( 225 ) ;
26
29
27
30
liquid . destroy ( ) ;
28
31
} ) ;
32
+
33
+ it ( 'outline & wave' , ( ) => {
34
+ const liquid = new Liquid ( createDiv ( ) , {
35
+ width : 600 ,
36
+ height : 300 ,
37
+ autoFit : false ,
38
+ percent : 0.3 ,
39
+ } ) ;
40
+
41
+ liquid . render ( ) ;
42
+ expect ( liquid . options . outline ) . toEqual ( { border : 2 , distance : 0 } ) ;
43
+ expect ( liquid . options . wave ) . toEqual ( { count : 3 , length : 192 } ) ;
44
+
45
+ expect ( liquid . chart . middleGroup . findAllByName ( 'wrap' ) [ 0 ] . attr ( 'r' ) ) . toBe ( 135 ) ;
46
+ expect ( liquid . chart . middleGroup . findAllByName ( 'wrap' ) [ 0 ] . attr ( 'lineWidth' ) ) . toBe ( 2 ) ;
47
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waterwave-path' ) . length ) . toBe ( 3 ) ;
48
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waterwave-path' ) [ 0 ] . get ( 'animations' ) [ 0 ] . toAttrs . matrix [ 6 ] ) . toBe (
49
+ 192
50
+ ) ;
51
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waves' ) [ 0 ] . get ( 'clipShape' ) . attr ( 'r' ) ) . toBe ( 135 ) ;
52
+
53
+ liquid . update ( {
54
+ outline : {
55
+ border : 4 ,
56
+ distance : 8 ,
57
+ } ,
58
+ wave : {
59
+ count : 5 ,
60
+ length : 128 ,
61
+ } ,
62
+ } ) ;
63
+
64
+ expect ( liquid . options . outline ) . toEqual ( { border : 4 , distance : 8 } ) ;
65
+ expect ( liquid . options . wave ) . toEqual ( { count : 5 , length : 128 } ) ;
66
+
67
+ expect ( liquid . chart . middleGroup . findAllByName ( 'wrap' ) [ 0 ] . attr ( 'r' ) ) . toBe ( 135 ) ;
68
+ expect ( liquid . chart . middleGroup . findAllByName ( 'wrap' ) [ 0 ] . attr ( 'lineWidth' ) ) . toBe ( 4 ) ;
69
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waterwave-path' ) . length ) . toBe ( 5 ) ;
70
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waterwave-path' ) [ 0 ] . get ( 'animations' ) [ 0 ] . toAttrs . matrix [ 6 ] ) . toBe (
71
+ 128
72
+ ) ;
73
+ expect ( liquid . chart . middleGroup . findAllByName ( 'waves' ) [ 0 ] . get ( 'clipShape' ) . attr ( 'r' ) ) . toBe ( 127 ) ;
74
+
75
+ liquid . destroy ( ) ;
76
+ } ) ;
77
+
29
78
it ( 'change data' , ( ) => {
30
79
const liquid = new Liquid ( createDiv ( ) , {
31
80
width : 600 ,
0 commit comments