@@ -192,7 +192,7 @@ describe('table', function() {
192
192
} ) ;
193
193
} ) ;
194
194
195
- describe ( 'basic use' , function ( ) {
195
+ describe ( 'basic use and basic data restyling ' , function ( ) {
196
196
var mockCopy ,
197
197
gd ;
198
198
@@ -211,7 +211,7 @@ describe('table', function() {
211
211
expect ( gd . data . length ) . toEqual ( 1 ) ;
212
212
expect ( gd . data [ 0 ] . header . values . length ) . toEqual ( 7 ) ;
213
213
expect ( gd . data [ 0 ] . cells . values . length ) . toEqual ( 7 ) ;
214
- expect ( document . querySelectorAll ( '.' + cn . yColumn ) . length ) . toEqual ( 7 ) ; // one dimension is `visible: false`
214
+ expect ( document . querySelectorAll ( '.' + cn . yColumn ) . length ) . toEqual ( 7 ) ;
215
215
} ) ;
216
216
217
217
it ( 'Calling `Plotly.plot` again should add the new table trace' , function ( done ) {
@@ -269,7 +269,7 @@ describe('table', function() {
269
269
. then ( done ) ;
270
270
} ) ;
271
271
272
- it ( 'Calling `Plotly.relayout` with string should amend the preexisting parcoords ' , function ( done ) {
272
+ it ( 'Calling `Plotly.relayout` with string should amend the preexisting table ' , function ( done ) {
273
273
expect ( gd . layout . width ) . toEqual ( 1000 ) ;
274
274
Plotly . relayout ( gd , 'width' , 500 ) . then ( function ( ) {
275
275
expect ( gd . data . length ) . toEqual ( 1 ) ;
@@ -278,7 +278,7 @@ describe('table', function() {
278
278
} ) ;
279
279
} ) ;
280
280
281
- it ( 'Calling `Plotly.relayout` with object should amend the preexisting parcoords ' , function ( done ) {
281
+ it ( 'Calling `Plotly.relayout` with object should amend the preexisting table ' , function ( done ) {
282
282
expect ( gd . layout . width ) . toEqual ( 1000 ) ;
283
283
Plotly . relayout ( gd , { width : 500 } ) . then ( function ( ) {
284
284
expect ( gd . data . length ) . toEqual ( 1 ) ;
@@ -287,4 +287,46 @@ describe('table', function() {
287
287
} ) ;
288
288
} ) ;
289
289
} ) ;
290
+
291
+ describe ( 'more restyling tests with scenegraph queries' , function ( ) {
292
+ var mockCopy ,
293
+ gd ;
294
+
295
+ beforeEach ( function ( done ) {
296
+ mockCopy = Lib . extendDeep ( { } , mock2 ) ;
297
+ gd = createGraphDiv ( ) ;
298
+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
299
+ } ) ;
300
+
301
+ it ( 'Calling `Plotly.restyle` for a `header.values` change should amend the preexisting one' , function ( done ) {
302
+
303
+ function restyleValues ( what , fun , setterValue ) {
304
+
305
+ var value = Lib . isArray ( setterValue ) ? setterValue [ 0 ] : setterValue ;
306
+
307
+ return function ( ) {
308
+ return Plotly . restyle ( gd , what , setterValue ) . then ( function ( ) {
309
+ expect ( fun ( gd ) ) . toEqual ( value , what + ':::' + value ) ;
310
+ expect ( document . querySelectorAll ( '.' + cn . yColumn ) . length ) . toEqual ( 2 ) ;
311
+ expect ( document . querySelectorAll ( '.' + cn . columnBlock ) . length ) . toEqual ( 6 ) ;
312
+ expect ( document . querySelectorAll ( '.' + cn . columnCell ) . length ) . toEqual ( 6 ) ;
313
+ expect ( document . querySelectorAll ( '.' + cn . cellRect ) . length ) . toEqual ( 6 ) ;
314
+ expect ( document . querySelectorAll ( '.' + cn . cellTextHolder ) . length ) . toEqual ( 6 ) ;
315
+ } ) ;
316
+ } ;
317
+ }
318
+
319
+ restyleValues ( 'cells.fill.color' , function ( gd ) { return gd . data [ 0 ] . cells . fill . color ; } , [ [ 'green' , 'red' ] ] ) ( )
320
+ . then ( restyleValues ( 'cells.line.color' , function ( gd ) { return gd . data [ 0 ] . cells . line . color ; } , [ [ 'magenta' , 'blue' ] ] ) )
321
+ . then ( restyleValues ( 'cells.line.width' , function ( gd ) { return gd . data [ 0 ] . cells . line . width ; } , [ [ 5 , 3 ] ] ) )
322
+ . then ( restyleValues ( 'cells.format' , function ( gd ) { return gd . data [ 0 ] . cells . format ; } , [ [ '' , '' ] ] ) )
323
+ . then ( restyleValues ( 'cells.prefix' , function ( gd ) { return gd . data [ 0 ] . cells . prefix ; } , [ [ 'p1' ] ] ) )
324
+ . then ( restyleValues ( 'cells.suffix' , function ( gd ) { return gd . data [ 0 ] . cells . suffix ; } , [ [ 's1' ] ] ) )
325
+ . then ( restyleValues ( 'header.fill.color' , function ( gd ) { return gd . data [ 0 ] . header . fill . color ; } , [ [ 'yellow' , 'purple' ] ] ) )
326
+ . then ( restyleValues ( 'header.line.color' , function ( gd ) { return gd . data [ 0 ] . header . line . color ; } , [ [ 'green' , 'red' ] ] ) )
327
+ . then ( restyleValues ( 'header.line.width' , function ( gd ) { return gd . data [ 0 ] . header . line . width ; } , [ [ 2 , 6 ] ] ) )
328
+ . then ( restyleValues ( 'header.format' , function ( gd ) { return gd . data [ 0 ] . header . format ; } , [ [ '' , '' ] ] ) )
329
+ . then ( done ) ;
330
+ } ) ;
331
+ } ) ;
290
332
} ) ;
0 commit comments