Skip to content

Commit 3c73301

Browse files
committed
use toBeCloseTo for to assert numbers
1 parent 69d9c8c commit 3c73301

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/jasmine/tests/select_test.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,13 @@ describe('Test select box and lasso per trace:', function() {
414414
pts.forEach(function(p, i) {
415415
var e = expected[i] || [];
416416
keys.forEach(function(k, j) {
417-
expect(p[k])
418-
.toBe(e[j], msg + 'selected pt ' + i + ' - ' + k + ' val');
417+
var msgFull = msg + 'selected pt ' + i + ' - ' + k + ' val';
418+
419+
if(typeof e[j] === 'number') {
420+
expect(p[k]).toBeCloseTo(e[j], 1, msgFull);
421+
} else {
422+
expect(p[k]).toBe(e[j], msgFull);
423+
}
419424
});
420425
});
421426

@@ -740,10 +745,10 @@ describe('Test select box and lasso per trace:', function() {
740745
[0, 4.9, 0.371], [0, 5, 0.368], [0, 5.1, 0.356], [0, 5.2, 0.336],
741746
[0, 5.3, 0.309], [0, 5.4, 0.275], [0, 5.5, 0.235], [0, 5.6, 0.192],
742747
[0, 5.7, 0.145],
743-
[1, 5.1, 0.485], [1, 5.2, 0.40900000000000003], [1, 5.3, 0.327],
744-
[1, 5.4, 0.24000000000000002], [1, 5.5, 0.149], [1, 5.6, 0.059],
745-
[2, 4.9, 0.473], [2, 5, 0.36800000000000005], [2, 5.1, 0.258],
746-
[2, 5.2, 0.14600000000000002], [2, 5.3, 0.03600000000000003]
748+
[1, 5.1, 0.485], [1, 5.2, 0.409], [1, 5.3, 0.327],
749+
[1, 5.4, 0.24], [1, 5.5, 0.149], [1, 5.6, 0.059],
750+
[2, 4.9, 0.473], [2, 5, 0.368], [2, 5.1, 0.258],
751+
[2, 5.2, 0.146], [2, 5.3, 0.036]
747752
]);
748753
assertLassoPoints([
749754
[4.87, 5.74, 5.74, 4.87, 4.87],
@@ -762,8 +767,8 @@ describe('Test select box and lasso per trace:', function() {
762767
function() {
763768
assertPoints([
764769
[0, 4.9, 0.371], [0, 5, 0.368], [0, 5.1, 0.356], [0, 5.2, 0.336],
765-
[1, 5.1, 0.485], [1, 5.2, 0.40900000000000003],
766-
[2, 4.9, 0.473], [2, 5, 0.36800000000000005]
770+
[1, 5.1, 0.485], [1, 5.2, 0.41],
771+
[2, 4.9, 0.473], [2, 5, 0.37]
767772
]);
768773
assertRanges([[4.87, 5.22], [0.31, 0.53]]);
769774
},

0 commit comments

Comments
 (0)