Skip to content

Commit 1d7b066

Browse files
committed
test: add range slider rrelayout test cases
1 parent 74607d4 commit 1d7b066

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

test/jasmine/tests/range_slider_test.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,78 @@ describe('the range slider', function() {
197197
.then(done);
198198
});
199199

200+
it('should relayout with style options', function(done) {
201+
var bg = children[0],
202+
maskMin = children[2],
203+
maskMax = children[3];
204+
205+
var maskMinWidth, maskMaxWidth;
206+
207+
Plotly.relayout(gd, 'xaxis.range', [5, 10]).then(function() {
208+
maskMinWidth = +maskMin.getAttribute('width'),
209+
maskMaxWidth = +maskMax.getAttribute('width');
210+
211+
return Plotly.relayout(gd, 'xaxis.rangeslider.bgcolor', 'red');
212+
})
213+
.then(function() {
214+
expect(+maskMin.getAttribute('width')).toEqual(maskMinWidth);
215+
expect(+maskMax.getAttribute('width')).toEqual(maskMaxWidth);
216+
217+
expect(bg.getAttribute('fill')).toBe('red');
218+
expect(bg.getAttribute('stroke')).toBe('black');
219+
expect(bg.getAttribute('stroke-width')).toBe('2');
220+
221+
return Plotly.relayout(gd, 'xaxis.rangeslider.bordercolor', 'blue');
222+
})
223+
.then(function() {
224+
expect(+maskMin.getAttribute('width')).toEqual(maskMinWidth);
225+
expect(+maskMax.getAttribute('width')).toEqual(maskMaxWidth);
226+
227+
expect(bg.getAttribute('fill')).toBe('red');
228+
expect(bg.getAttribute('stroke')).toBe('blue');
229+
expect(bg.getAttribute('stroke-width')).toBe('2');
230+
231+
return Plotly.relayout(gd, 'xaxis.rangeslider.borderwidth', 3);
232+
})
233+
.then(function() {
234+
expect(+maskMin.getAttribute('width')).toEqual(maskMinWidth);
235+
expect(+maskMax.getAttribute('width')).toEqual(maskMaxWidth);
236+
237+
expect(bg.getAttribute('fill')).toBe('red');
238+
expect(bg.getAttribute('stroke')).toBe('blue');
239+
expect(bg.getAttribute('stroke-width')).toBe('3');
240+
})
241+
.then(done);
242+
});
243+
244+
it('should relayout on size / domain udpate', function(done) {
245+
var maskMin = children[2],
246+
maskMax = children[3];
247+
248+
Plotly.relayout(gd, 'xaxis.range', [5, 10]).then(function() {
249+
expect(+maskMin.getAttribute('width')).toBeCloseTo(63.16, 0);
250+
expect(+maskMax.getAttribute('width')).toBeCloseTo(492.67, 0);
251+
252+
return Plotly.relayout(gd, 'xaxis.domain', [0.3, 0.7]);
253+
})
254+
.then(function() {
255+
var maskMin = children[2],
256+
maskMax = children[3];
257+
258+
expect(+maskMin.getAttribute('width')).toBeCloseTo(25.26, 0);
259+
expect(+maskMax.getAttribute('width')).toBeCloseTo(197.06, 0);
260+
261+
return Plotly.relayout(gd, 'width', 400);
262+
})
263+
.then(function() {
264+
var maskMin = children[2],
265+
maskMax = children[3];
266+
267+
expect(+maskMin.getAttribute('width')).toBeCloseTo(9.22, 0);
268+
expect(+maskMax.getAttribute('width')).toBeCloseTo(71.95, 0);
269+
270+
})
271+
.then(done);
200272
});
201273
});
202274

0 commit comments

Comments
 (0)