@@ -524,5 +524,44 @@ describe('Test colorbar:', function() {
524
524
. catch ( failTest )
525
525
. then ( done ) ;
526
526
} ) ;
527
+
528
+ it ( 'creates the same colorbars attributes in newPlot and react' , function ( done ) {
529
+ var z = [ [ 1 , 10 ] , [ 100 , 1000 ] ] ;
530
+
531
+ var expectedAttrs = [ ] ;
532
+ var actualAttrs = [ ] ;
533
+
534
+ Plotly . newPlot ( gd , [ { type : 'contour' , z : z } ] )
535
+ . then ( function ( ) {
536
+ var colorbars = d3 . select ( gd ) . selectAll ( '.colorbar' ) ;
537
+ colorbars . selectAll ( '.cbfill' ) . each ( function ( ) {
538
+ var attrsForElem = { } ;
539
+ for ( var i = 0 ; i < this . attributes . length ; i ++ ) {
540
+ var attr = this . attributes . item ( i ) ;
541
+ attrsForElem [ attr . name ] = attr . value ;
542
+ }
543
+ expectedAttrs . push ( attrsForElem ) ;
544
+ } ) ;
545
+
546
+ return Plotly . newPlot ( gd , [ { type : 'heatmap' , z : z } ] )
547
+ . then ( function ( ) {
548
+ return Plotly . react ( gd , [ { type : 'contour' , z : z } ] ) ;
549
+ } ) ;
550
+ } )
551
+ . then ( function ( ) {
552
+ var colorbars = d3 . select ( gd ) . selectAll ( '.colorbar' ) ;
553
+ colorbars . selectAll ( '.cbfill' ) . each ( function ( ) {
554
+ var attrsForElem = { } ;
555
+ for ( var i = 0 ; i < this . attributes . length ; i ++ ) {
556
+ var attr = this . attributes . item ( i ) ;
557
+ attrsForElem [ attr . name ] = attr . value ;
558
+ }
559
+ actualAttrs . push ( attrsForElem ) ;
560
+ } ) ;
561
+ expect ( actualAttrs ) . toEqual ( expectedAttrs ) ;
562
+ } )
563
+ . catch ( failTest )
564
+ . then ( done ) ;
565
+ } ) ;
527
566
} ) ;
528
567
} ) ;
0 commit comments