Skip to content

Commit bb6c720

Browse files
committed
use bg rect instead of grids for assertPlotSize
1 parent 3deab4c commit bb6c720

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

test/jasmine/assets/custom_assertions.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,9 @@ exports.assertPlotSize = function(opts, msg) {
232232
var widthLessThan = opts.widthLessThan;
233233
var heightLessThan = opts.heightLessThan;
234234

235-
var actualWidth = d3.select('.ygrid').node().getBoundingClientRect().width;
236-
var actualHeight = d3.select('.xgrid').node().getBoundingClientRect().height;
235+
var plotBB = d3.select('.bglayer .bg').node().getBoundingClientRect();
236+
var actualWidth = plotBB.width;
237+
var actualHeight = plotBB.height;
237238

238239
var msgPlus = msg ? ': ' + msg : '';
239240

test/jasmine/tests/colorbar_test.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var Colorbar = require('@src/components/colorbar');
55
var createGraphDiv = require('../assets/create_graph_div');
66
var destroyGraphDiv = require('../assets/destroy_graph_div');
77
var failTest = require('../assets/fail_test');
8+
var assertPlotSize = require('../assets/custom_assertions').assertPlotSize;
89

910

1011
describe('Test colorbar:', function() {
@@ -127,11 +128,7 @@ describe('Test colorbar:', function() {
127128
var colorbars = d3.select(gd).selectAll('.colorbar');
128129
expect(colorbars.size()).toBe(present ? 1 : 0);
129130

130-
var yLines = d3.select(gd).selectAll('.ygrid');
131-
expect(yLines.size()).toBeGreaterThan(0);
132-
var yLineWidth = +yLines.node().getBoundingClientRect().width;
133-
if(expandedMargin) expect(yLineWidth).toBeLessThan(400);
134-
else expect(yLineWidth).toBe(400);
131+
assertPlotSize(expandedMargin ? {widthLessThan: 400} : {width: 400});
135132
}
136133

137134
Plotly.newPlot(gd, [{
@@ -170,11 +167,7 @@ describe('Test colorbar:', function() {
170167
var colorbars = d3.select(gd).selectAll('.colorbar');
171168
expect(colorbars.size()).toBe(present ? 1 : 0);
172169

173-
var yLines = d3.select(gd).selectAll('.ygrid');
174-
expect(yLines.size()).toBeGreaterThan(0);
175-
var yLineWidth = +yLines.node().getBoundingClientRect().width;
176-
if(expandedMargin) expect(yLineWidth).toBeLessThan(400);
177-
else expect(yLineWidth).toBe(400);
170+
assertPlotSize(expandedMargin ? {widthLessThan: 400} : {width: 400});
178171
}
179172

180173
Plotly.newPlot(gd, [{

0 commit comments

Comments
 (0)