Skip to content

Commit

Permalink
add margin of error for funnel restyle test
Browse files Browse the repository at this point in the history
  • Loading branch information
emilykl committed Jan 22, 2025
1 parent 8e0d77b commit c71a251
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/jasmine/tests/funnel_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,14 @@ describe('A funnel 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 @@ -969,7 +969,7 @@ describe('A funnel 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

0 comments on commit c71a251

Please sign in to comment.