@@ -40,6 +40,40 @@ describe('core', () => {
40
40
line . destroy ( ) ;
41
41
} ) ;
42
42
43
+ it ( 'updateOption without render' , ( ) => {
44
+ const options = {
45
+ width : 400 ,
46
+ height : 300 ,
47
+ data : [
48
+ { date : '12-01' , value : 1 , type : 'bb' } ,
49
+ { date : '12-02' , value : 12 , type : 'bb' } ,
50
+ ] ,
51
+ xField : 'date' ,
52
+ yField : 'value' ,
53
+ seriesField : 'type' ,
54
+ } ;
55
+ const line = new Line ( createDiv ( ) , options ) ;
56
+
57
+ line . render ( ) ;
58
+
59
+ // @ts -ignore
60
+ line . updateOption ( {
61
+ data : [ ...line . options . data , { date : '12-01' , value : 4 , type : 'cc' } , { date : '12-02' , value : 19 , type : 'cc' } ] ,
62
+ } ) ;
63
+
64
+ expect ( line . chart . geometries [ 0 ] . elements . length ) . toBe ( 1 ) ;
65
+
66
+ line . render ( ) ;
67
+ expect ( line . chart . geometries [ 0 ] . elements . length ) . toBe ( 2 ) ;
68
+
69
+ line . update ( {
70
+ data : [ ...line . options . data , { date : '12-01' , value : 4 , type : 'dd' } , { date : '12-02' , value : 19 , type : 'dd' } ] ,
71
+ } ) ;
72
+ expect ( line . chart . geometries [ 0 ] . elements . length ) . toBe ( 3 ) ;
73
+
74
+ line . destroy ( ) ;
75
+ } ) ;
76
+
43
77
it ( 'update mix with default options' , ( ) => {
44
78
const options = {
45
79
width : 400 ,
@@ -53,9 +87,7 @@ describe('core', () => {
53
87
line . render ( ) ;
54
88
const curOptions = clone ( line . options ) ;
55
89
56
- line . update ( { ...options , width : 500 } ) ;
57
-
58
- line . render ( ) ;
90
+ line . update ( { width : 500 } ) ;
59
91
60
92
expect ( isEqual ( line . options , deepMix ( curOptions , { ...options , width : 500 } ) ) ) . toBeTruthy ( ) ;
61
93
0 commit comments