1
- import { transformData , isDrillDown } from '../../../../src/plots/treemap/utils' ;
1
+ import { transformData , isDrillDown , getFommatInteractions } from '../../../../src/plots/treemap/utils' ;
2
2
3
3
const data1 = {
4
4
name : 'root' ,
@@ -52,10 +52,10 @@ const data2 = {
52
52
] ,
53
53
} ;
54
54
55
- // 自己有分类,父类有分类
56
- // 没有,父类有
57
- // 自己有,父类没有 ,
58
- // 自己没有,父类没有
55
+ // 叶节点有分类,父节点有分类
56
+ // 叶节点没有,父节点有
57
+ // 叶节点有,父节点没有 ,
58
+ // 叶节点没有,父节点没有
59
59
60
60
const data3 = {
61
61
name : 'root' ,
@@ -110,8 +110,12 @@ describe('treemap transformData', () => {
110
110
it ( 'isDrillDown' , ( ) => {
111
111
expect ( isDrillDown ( undefined ) ) . toBeFalsy ( ) ;
112
112
expect ( isDrillDown ( [ ] ) ) . toBeFalsy ( ) ;
113
- expect ( isDrillDown ( [ { type : 'asas' } ] ) ) . toBeFalsy ( ) ;
114
- expect ( isDrillDown ( [ { type : 'treemap-drill-down' } ] ) ) . toBeTruthy ( ) ;
113
+ expect ( isDrillDown ( [ {
114
+ type : 'asas'
115
+ } ] ) ) . toBeFalsy ( ) ;
116
+ expect ( isDrillDown ( [ {
117
+ type : 'treemap-drill-down'
118
+ } ] ) ) . toBeTruthy ( ) ;
115
119
} ) ;
116
120
117
121
it ( 'transformData, basic treemap' , ( ) => {
@@ -176,6 +180,7 @@ describe('treemap transformData', () => {
176
180
const data = transformData ( {
177
181
data : data1 ,
178
182
colorField : 'name' ,
183
+ openDrillDown : false ,
179
184
hierarchyConfig : {
180
185
tile : 'treemapDice' ,
181
186
} ,
@@ -199,4 +204,61 @@ describe('treemap transformData', () => {
199
204
} ) ;
200
205
expect ( data . length ) . toEqual ( 2 ) ;
201
206
} ) ;
207
+
208
+ it ( 'getFommatInteractions' , ( ) => {
209
+ expect ( getFommatInteractions ( undefined , undefined ) ) . toEqual ( undefined ) ;
210
+ expect ( getFommatInteractions ( undefined , {
211
+ tile : 'treemapSlice'
212
+ } ) ) . toEqual ( undefined ) ;
213
+ expect ( getFommatInteractions ( [ ] , {
214
+ tile : 'treemapSlice'
215
+ } ) ) . toEqual ( [ ] ) ;
216
+ expect ( getFommatInteractions ( [ {
217
+ type : 'treemap'
218
+ } ] , {
219
+ tile : 'treemapSlice'
220
+ } ) )
221
+ . toEqual ( [ {
222
+ type : 'treemap'
223
+ } ] ) ;
224
+ expect ( getFommatInteractions (
225
+ [ {
226
+ type : 'treemap'
227
+ } ,
228
+ {
229
+ type : 'treemap-drill-down'
230
+ }
231
+ ] , {
232
+ tile : 'treemapSlice'
233
+ } ) )
234
+ . toEqual ( [ {
235
+ type : 'treemap'
236
+ } ,
237
+ {
238
+ type : 'treemap-drill-down' ,
239
+ cfg : {
240
+ hierarchyConfig : {
241
+ tile : 'treemapSlice'
242
+ }
243
+ }
244
+ } ] ) ;
245
+
246
+ expect ( getFommatInteractions (
247
+ [ {
248
+ type : 'treemap'
249
+ } ,
250
+ {
251
+ type : 'treemap-drill-down'
252
+ }
253
+ ] , undefined ) )
254
+ . toEqual ( [ {
255
+ type : 'treemap'
256
+ } ,
257
+ {
258
+ type : 'treemap-drill-down' ,
259
+ cfg : {
260
+ hierarchyConfig : undefined
261
+ }
262
+ } ] ) ;
263
+ } ) ;
202
264
} ) ;
0 commit comments