Skip to content

Commit 2f6cd6f

Browse files
committed
fix jasmine tests
1 parent 1d47d05 commit 2f6cd6f

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

test/jasmine/tests/axes_test.js

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,16 +4268,22 @@ describe('Test axes', function() {
42684268
var op = parts[0];
42694269

42704270
var method = {
4271-
'=': 'toBe',
4271+
'=': 'toBeCloseTo',
42724272
'~=': 'toBeWithin',
42734273
grew: 'toBeGreaterThan',
42744274
shrunk: 'toBeLessThan',
4275-
initial: 'toBe'
4275+
initial: 'toBeCloseTo'
42764276
}[op];
42774277

42784278
var val = op === 'initial' ? initialSize[k] : previousSize[k];
42794279
var msgk = msg + ' ' + k + (parts[1] ? ' |' + parts[1] : '');
4280-
var args = op === '~=' ? [val, 1.1, msgk] : [val, msgk, ''];
4280+
var args = [val];
4281+
if(op === '~=') {
4282+
args.push(1.1);
4283+
} else if(method === 'toBeCloseTo') {
4284+
args.push(3);
4285+
}
4286+
args.push(msgk);
42814287

42824288
expect(actual[k])[method](args[0], args[1], args[2]);
42834289
}
@@ -4313,7 +4319,7 @@ describe('Test axes', function() {
43134319
width: 600, height: 600
43144320
})
43154321
.then(function() {
4316-
expect(gd._fullLayout.xaxis._tickAngles.xtick).toBe(30);
4322+
expect(gd._fullLayout.xaxis._tickAngles.xtick).toBeCloseTo(30, 3);
43174323

43184324
var gs = gd._fullLayout._size;
43194325
initialSize = Lib.extendDeep({}, gs);
@@ -4485,13 +4491,22 @@ describe('Test axes', function() {
44854491
var op = parts[0];
44864492

44874493
var method = {
4488-
'=': 'toBe',
4494+
'=': 'toBeCloseTo',
4495+
'~=': 'toBeWithin',
44894496
grew: 'toBeGreaterThan',
4497+
shrunk: 'toBeLessThan',
4498+
initial: 'toBeCloseTo'
44904499
}[op];
44914500

44924501
var val = initialSize[k];
44934502
var msgk = msg + ' ' + k + (parts[1] ? ' |' + parts[1] : '');
4494-
var args = op === '~=' ? [val, 1.1, msgk] : [val, msgk, ''];
4503+
var args = [val];
4504+
if(op === '~=') {
4505+
args.push(1.1);
4506+
} else if(method === 'toBeCloseTo') {
4507+
args.push(3);
4508+
}
4509+
args.push(msgk);
44954510

44964511
expect(actual[k])[method](args[0], args[1], args[2]);
44974512
}
@@ -4526,7 +4541,7 @@ describe('Test axes', function() {
45264541
width: 600, height: 600
45274542
})
45284543
.then(function() {
4529-
expect(gd._fullLayout.xaxis._tickAngles.xtick).toBe(30);
4544+
expect(gd._fullLayout.xaxis._tickAngles.xtick).toBeCloseTo(30, 3);
45304545

45314546
var gs = gd._fullLayout._size;
45324547
initialSize = Lib.extendDeep({}, gs);

test/jasmine/tests/plots_test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ describe('Test Plots with automargin and minreducedwidth/height', function() {
13361336

13371337
afterEach(destroyGraphDiv);
13381338

1339-
it('should resize the plot area when tweaking min-reduced width & height', function(done) {
1339+
fit('should resize the plot area when tweaking min-reduced width & height', function(done) {
13401340
function assert(attr, exp) {
13411341
var xy = d3Select('rect.nsewdrag')[0][0];
13421342
expect(xy.getAttribute(attr)).toEqual(exp);
@@ -1360,7 +1360,10 @@ describe('Test Plots with automargin and minreducedwidth/height', function() {
13601360
assert('height', '100');
13611361
})
13621362
.then(function() {
1363-
return Plotly.relayout(gd, 'minreducedwidth', 100);
1363+
// force tickangle to 90 so when we increase the width the x axis labels
1364+
// don't revert to 30 degrees, giving us a larger height
1365+
// this is a cool effect, but not what we're testing here!
1366+
return Plotly.relayout(gd, {minreducedwidth: 100, 'xaxis.tickangle': 90});
13641367
})
13651368
.then(function() {
13661369
assert('width', '100');

0 commit comments

Comments
 (0)