Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add margin of error to assertTextIsInsidePath
  • Loading branch information
emilykl committed Jan 21, 2025
commit 7c418a50e8c52d1768d0f97c7becc883023efacc
12 changes: 6 additions & 6 deletions test/jasmine/tests/bar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1195,14 +1195,14 @@ describe('A bar plot', function() {
return node.querySelectorAll('g.point');
}

function assertTextIsInsidePath(textNode, pathNode) {
function assertTextIsInsidePath(textNode, pathNode, errorMargin=0) {
var textBB = textNode.getBoundingClientRect();
var pathBB = pathNode.getBoundingClientRect();

expect(pathBB.left).not.toBeGreaterThan(textBB.left);
expect(textBB.right).not.toBeGreaterThan(pathBB.right);
expect(pathBB.top).not.toBeGreaterThan(textBB.top);
expect(textBB.bottom).not.toBeGreaterThan(pathBB.bottom);
expect(pathBB.left - errorMargin).not.toBeGreaterThan(textBB.left);
expect(textBB.right - errorMargin).not.toBeGreaterThan(pathBB.right);
expect(pathBB.top - errorMargin).not.toBeGreaterThan(textBB.top);
expect(textBB.bottom - errorMargin).not.toBeGreaterThan(pathBB.bottom);
}

function assertTextIsAbovePath(textNode, pathNode) {
Expand Down Expand Up @@ -1828,7 +1828,7 @@ describe('A bar plot', function() {
assertTextIsInsidePath(text03, path03); // inside
assertTextIsInsidePath(text12, path12); // inside
assertTextIsInsidePath(text20, path20); // inside
assertTextIsInsidePath(text30, path30); // inside
assertTextIsInsidePath(text30, path30, 0.5); // inside
})
.then(done, done.fail);
});
Expand Down