Skip to content

Commit 684d05c

Browse files
committed
Update some tests in axes_test.js, because hidden labels no longer take up space.
Also use floating point comparison in "Test axes minor ticks"
1 parent 150ccd3 commit 684d05c

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

test/jasmine/tests/axes_test.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,8 @@ describe('Test axes', function() {
16961696

16971697
return Plotly.relayout(gd, 'xaxis.autorange', true);
16981698
}).then(function() {
1699-
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.37, 3.22], 1);
1699+
1700+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.27, 3.23], 1);
17001701
})
17011702
.then(done, done.fail);
17021703
});
@@ -1721,13 +1722,13 @@ describe('Test axes', function() {
17211722
width: 600,
17221723
height: 600
17231724
}).then(function() {
1724-
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.110, 2]);
1725+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.13, 2]);
17251726

17261727
return Plotly.relayout(gd, {
17271728
'xaxis.insiderange': [1, 3]
17281729
});
17291730
}).then(function() {
1730-
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.889, 3]);
1731+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.866, 3]);
17311732
}).then(done, done.fail);
17321733
});
17331734
});
@@ -4907,32 +4908,32 @@ describe('Test axes', function() {
49074908
})
49084909
.then(function() {
49094910
_assert('on labels (defaults)', {
4910-
ticks: [110.75, 350, 589.25],
4911-
gridLines: [110.75, 350, 589.25],
4911+
ticks: [108.75, 348, 587.25],
4912+
gridLines: [108.75, 348, 587.25],
49124913
tickLabels: [106.421, 345.671, 585.25]
49134914
});
49144915
return Plotly.relayout(gd, 'xaxis.tickson', 'boundaries');
49154916
})
49164917
.then(function() {
49174918
_assert('inside on boundaries', {
4918-
ticks: [230.369, 469.619], // N.B. first and last tick are clipped
4919-
gridLines: [230.369, 469.619],
4919+
ticks: [228.367, 467.617], // N.B. first and last tick are clipped
4920+
gridLines: [228.367, 467.617],
49204921
tickLabels: [106.421875, 345.671875, 585.25]
49214922
});
49224923
return Plotly.relayout(gd, 'xaxis.ticks', 'outside');
49234924
})
49244925
.then(function() {
49254926
_assert('outside on boundaries', {
4926-
ticks: [230.369, 469.619],
4927-
gridLines: [230.369, 469.619],
4927+
ticks: [228.367, 467.617],
4928+
gridLines: [228.367, 467.617],
49284929
tickLabels: [106.421875, 345.671875, 585.25]
49294930
});
49304931
return Plotly.restyle(gd, 'x', [[1, 2, 1]]);
49314932
})
49324933
.then(function() {
49334934
_assert('fallback to *labels* on non-category axes', {
4934-
ticks: [110.75, 206.449, 302.149, 397.85, 493.549, 589.25],
4935-
gridLines: [110.75, 206.449, 302.149, 397.85, 493.549, 589.25],
4935+
ticks: [108.75, 204.433, 300.133, 395.85, 491.533, 587.25],
4936+
gridLines: [108.75, 204.433, 300.133, 395.85, 491.533, 587.25],
49364937
tickLabels: [106.421, 197.121, 292.821, 388.521, 484.221, 584.921]
49374938
});
49384939
})
@@ -6901,6 +6902,18 @@ describe('Test axes', function() {
69016902
expect(positions).toEqual(expPositions);
69026903
}
69036904

6905+
function _assertClose(expPositions) {
6906+
var ax = gd._fullLayout.xaxis;
6907+
6908+
// minor positions
6909+
var positions =
6910+
ax._vals
6911+
.filter(function(d) { return d.minor; })
6912+
.map(function(d) { return d.x; });
6913+
6914+
expect(positions).toBeCloseToArray(expPositions);
6915+
}
6916+
69046917
it('minor tickvals', function(done) {
69056918
Plotly.newPlot(gd, {
69066919
data: [{
@@ -7127,7 +7140,7 @@ describe('Test axes', function() {
71277140
}
71287141
})
71297142
.then(function() {
7130-
_assert([ -0.22184874961635648, -0.1549019599857433, -0.09691001300805657, -0.04575749056067513, 0.4771212547196623, 0.6020599913279623, 0.7781512503836435, 0.8450980400142567, 0.9030899869919434, 0.9542425094393249, 1.4771212547196624, 1.6020599913279623, 1.7781512503836434, 1.8450980400142567, 1.9030899869919433, 1.9542425094393248, 2.477121254719662, 2.6020599913279625, 2.7781512503836434, 2.845098040014257, 2.9030899869919433, 2.9542425094393248, 3.477121254719662, 3.6020599913279625, 3.7781512503836434, 3.845098040014257, 3.9030899869919433, 3.9542425094393248 ]);
7143+
_assertClose([ -0.22184874961635648, -0.1549019599857433, -0.09691001300805657, -0.04575749056067513, 0.4771212547196623, 0.6020599913279623, 0.7781512503836435, 0.8450980400142567, 0.9030899869919434, 0.9542425094393249, 1.4771212547196624, 1.6020599913279623, 1.7781512503836434, 1.8450980400142567, 1.9030899869919433, 1.9542425094393248, 2.477121254719662, 2.6020599913279625, 2.7781512503836434, 2.845098040014257, 2.9030899869919433, 2.9542425094393248, 3.477121254719662, 3.6020599913279625, 3.7781512503836434, 3.845098040014257, 3.9030899869919433, 3.9542425094393248 ]);
71317144
})
71327145
.then(done, done.fail);
71337146
});
@@ -7169,7 +7182,7 @@ describe('Test axes', function() {
71697182
}
71707183
})
71717184
.then(function() {
7172-
_assert([ -0.017728766960431602, -0.00877392430750515, 0.008600171761917567, 0.017033339298780367, 0.025305865264770258, 0.03342375548694973, 0.049218022670181646, 0.056904851336472634, 0.06445798922691853, 0.07188200730612543, 0.08635983067474828, 0.09342168516223513, 0.10037054511756296, 0.10720996964786844, 0.12057393120584996, 0.1271047983648077, 0.13353890837021762, 0.13987908640123659, 0.15228834438305658, 0.15836249209524975, 0.1643528557844372, 0.17026171539495752, 0.18184358794477265, 0.18752072083646318, 0.1931245983544617, 0.1986570869544227, 0.20951501454263102, 0.21484384804769796, 0.22010808804005513, 0.22530928172586287, 0.23552844690754896, 0.24054924828259974, 0.24551266781414988, 0.250420002308894, 0.2600713879850748, 0.2648178230095364, 0.26951294421791616, 0.2741578492636797, 0.28330122870354935, 0.2878017299302258, 0.29225607135647574, 0.29666519026153076, 0.30535136944662333, 0.3096301674258983, 0.31386722036915293, 0.31806333496276107 ]);
7185+
_assertClose([ -0.017728766960431602, -0.00877392430750515, 0.008600171761917567, 0.017033339298780367, 0.025305865264770258, 0.03342375548694973, 0.049218022670181646, 0.056904851336472634, 0.06445798922691853, 0.07188200730612543, 0.08635983067474828, 0.09342168516223513, 0.10037054511756296, 0.10720996964786844, 0.12057393120584996, 0.1271047983648077, 0.13353890837021762, 0.13987908640123659, 0.15228834438305658, 0.15836249209524975, 0.1643528557844372, 0.17026171539495752, 0.18184358794477265, 0.18752072083646318, 0.1931245983544617, 0.1986570869544227, 0.20951501454263102, 0.21484384804769796, 0.22010808804005513, 0.22530928172586287, 0.23552844690754896, 0.24054924828259974, 0.24551266781414988, 0.250420002308894, 0.2600713879850748, 0.2648178230095364, 0.26951294421791616, 0.2741578492636797, 0.28330122870354935, 0.2878017299302258, 0.29225607135647574, 0.29666519026153076, 0.30535136944662333, 0.3096301674258983, 0.31386722036915293, 0.31806333496276107 ]);
71737186
})
71747187
.then(done, done.fail);
71757188
});
@@ -7191,7 +7204,7 @@ describe('Test axes', function() {
71917204
}
71927205
})
71937206
.then(function() {
7194-
_assert([ -0.30102999566398125, 0.30102999566398114, 0.6989700043360187, 1.3010299956639813, 1.6989700043360187, 2.3010299956639813, 2.6989700043360187, 3.3010299956639813, 3.6989700043360187, 4.301029995663981, 4.698970004336019, 5.301029995663981, 5.698970004336019, 6.301029995663981, 6.698970004336019, 7.301029995663981 ]);
7207+
_assertClose([ -0.30102999566398125, 0.30102999566398114, 0.6989700043360187, 1.3010299956639813, 1.6989700043360187, 2.3010299956639813, 2.6989700043360187, 3.3010299956639813, 3.6989700043360187, 4.301029995663981, 4.698970004336019, 5.301029995663981, 5.698970004336019, 6.301029995663981, 6.698970004336019, 7.301029995663981 ]);
71957208
})
71967209
.then(done, done.fail);
71977210
});
@@ -7213,7 +7226,7 @@ describe('Test axes', function() {
72137226
}
72147227
})
72157228
.then(function() {
7216-
_assert([ 0.17609125905568124, 0.3979400086720376, 0.5440680443502756, 0.6532125137753436, 0.7403626894942437, 0.8129133566428552, 0.8750612633916998, 0.9294189257142923, 0.9777236052888472, 1.0211892990699374, 1.0413926851582243, 1.0606978403536107 ]);
7229+
_assertClose([ 0.17609125905568124, 0.3979400086720376, 0.5440680443502756, 0.6532125137753436, 0.7403626894942437, 0.8129133566428552, 0.8750612633916998, 0.9294189257142923, 0.9777236052888472, 1.0211892990699374, 1.0413926851582243, 1.0606978403536107 ]);
72177230
})
72187231
.then(done, done.fail);
72197232
});
@@ -8139,11 +8152,11 @@ describe('more react tests', function() {
81398152

81408153
Plotly.newPlot(gd, fig1)
81418154
.then(function() {
8142-
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.110, 2]);
8155+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.134, 2]);
81438156

81448157
return Plotly.react(gd, fig2);
81458158
}).then(function() {
8146-
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.164, 2]);
8159+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.192, 2]);
81478160
}).then(done, done.fail);
81488161
});
81498162
});

0 commit comments

Comments
 (0)