Skip to content

Commit 018be00

Browse files
author
anaplian
committed
Add test to check colorbar attrs match on newPlot/react
1 parent 9319e2e commit 018be00

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/jasmine/tests/colorbar_test.js

+39
Original file line numberDiff line numberDiff line change
@@ -524,5 +524,44 @@ describe('Test colorbar:', function() {
524524
.catch(failTest)
525525
.then(done);
526526
});
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+
});
527566
});
528567
});

0 commit comments

Comments
 (0)