Skip to content

Commit 7c418a5

Browse files
committed
add margin of error to assertTextIsInsidePath
1 parent 39520c1 commit 7c418a5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: test/jasmine/tests/bar_test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1195,14 +1195,14 @@ describe('A bar plot', function() {
11951195
return node.querySelectorAll('g.point');
11961196
}
11971197

1198-
function assertTextIsInsidePath(textNode, pathNode) {
1198+
function assertTextIsInsidePath(textNode, pathNode, errorMargin=0) {
11991199
var textBB = textNode.getBoundingClientRect();
12001200
var pathBB = pathNode.getBoundingClientRect();
12011201

1202-
expect(pathBB.left).not.toBeGreaterThan(textBB.left);
1203-
expect(textBB.right).not.toBeGreaterThan(pathBB.right);
1204-
expect(pathBB.top).not.toBeGreaterThan(textBB.top);
1205-
expect(textBB.bottom).not.toBeGreaterThan(pathBB.bottom);
1202+
expect(pathBB.left - errorMargin).not.toBeGreaterThan(textBB.left);
1203+
expect(textBB.right - errorMargin).not.toBeGreaterThan(pathBB.right);
1204+
expect(pathBB.top - errorMargin).not.toBeGreaterThan(textBB.top);
1205+
expect(textBB.bottom - errorMargin).not.toBeGreaterThan(pathBB.bottom);
12061206
}
12071207

12081208
function assertTextIsAbovePath(textNode, pathNode) {
@@ -1828,7 +1828,7 @@ describe('A bar plot', function() {
18281828
assertTextIsInsidePath(text03, path03); // inside
18291829
assertTextIsInsidePath(text12, path12); // inside
18301830
assertTextIsInsidePath(text20, path20); // inside
1831-
assertTextIsInsidePath(text30, path30); // inside
1831+
assertTextIsInsidePath(text30, path30, 0.5); // inside
18321832
})
18331833
.then(done, done.fail);
18341834
});

0 commit comments

Comments
 (0)