Skip to content

Commit 50148c2

Browse files
committed
try
1 parent 4a2aeed commit 50148c2

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

test/jasmine/tests/bar_test.js

+18-25
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,6 @@ describe('bar hover', function() {
681681

682682
var gd;
683683

684-
var TOL = 0.1;
685-
686684
beforeAll(function() {
687685
jasmine.addMatchers(customMatchers);
688686
});
@@ -708,12 +706,19 @@ describe('bar hover', function() {
708706
var pt = Bar.hoverPoints(pointData, xval, yval, closest)[0];
709707

710708
return {
711-
index: pt.index,
712-
color: pt.color,
713-
pos: [pt.x0, pt.x1, pt.y0, pt.y1, pt.xLabelVal, pt.yLabelVal]
709+
style: [pt.index, pt.color, pt.xLabelVal, pt.yLabelVal],
710+
pos: [pt.x0, pt.x1, pt.y0, pt.y1]
714711
};
715712
}
716713

714+
function assertPos(actual, expected) {
715+
var TOL = 5;
716+
717+
actual.forEach(function(p, i) {
718+
expect(p).toBeWithin(expected[i], TOL);
719+
});
720+
}
721+
717722
describe('with orientation *v*', function() {
718723
beforeAll(function(done) {
719724
gd = createGraphDiv();
@@ -726,21 +731,15 @@ describe('bar hover', function() {
726731
it('should return the correct hover point data (case x)', function() {
727732
var out = _hover(gd, 0, 0, 'x');
728733

729-
expect(out.index).toEqual(0);
730-
expect(out.color).toEqual('rgb(255, 102, 97)');
731-
expect(out.pos).toBeCloseToArray([
732-
11.87, 106.8, 152.76, 152.76, 0, 13.23
733-
], TOL);
734+
expect(out.style).toEqual([0, 'rgb(255, 102, 97)', 0, 13.23]);
735+
assertPos(out.pos, [11.87, 106.8, 152.76, 152.76]);
734736
});
735737

736738
it('should return the correct hover point data (case closest)', function() {
737739
var out = _hover(gd, -0.2, 12, 'closest');
738740

739-
expect(out.index).toEqual(0);
740-
expect(out.color).toEqual('rgb(255, 102, 97)');
741-
expect(out.pos).toBeCloseToArray([
742-
11.87, 59.33, 152.76, 152.76, 0, 13.23
743-
], TOL);
741+
expect(out.style).toEqual([0, 'rgb(255, 102, 97)', 0, 13.23]);
742+
assertPos(out.pos, [11.87, 59.33, 152.76, 152.76]);
744743
});
745744
});
746745

@@ -756,21 +755,15 @@ describe('bar hover', function() {
756755
it('should return the correct hover point data (case y)', function() {
757756
var out = _hover(gd, 185.645, 0.15, 'y');
758757

759-
expect(out.index).toEqual(0);
760-
expect(out.color).toEqual('#1f77b4');
761-
expect(out.pos).toBeCloseToArray([
762-
182.88, 182.88, 214.5, 170.5, 75, 0
763-
], TOL);
758+
expect(out.style).toEqual([0, '#1f77b4', 75, 0]);
759+
assertPos(out.pos, [182.88, 182.88, 214.5, 170.5]);
764760
});
765761

766762
it('should return the correct hover point data (case closest)', function() {
767763
var out = _hover(gd, 135.88, -0.15, 'closest');
768764

769-
expect(out.index).toEqual(0);
770-
expect(out.color).toEqual('#1f77b4');
771-
expect(out.pos).toBeCloseToArray([
772-
182.88, 182.88, 214.5, 192.5, 75, 0
773-
], TOL);
765+
expect(out.style).toEqual([0, '#1f77b4', 75, 0]);
766+
assertPos(out.pos, [182.88, 182.88, 214.5, 192.5]);
774767
});
775768
});
776769

0 commit comments

Comments
 (0)