Commit b8e0087a authored by Robert Knight's avatar Robert Knight

Allow for approximate equality in range-util tests

Several tests in range-util-test.js started failing locally after the
most recent Puppeteer upgrade with actual and expected values differing
by up to 1.0.

Change the tests to check for approximate equality, which is all that is
required for this use case.
parent f993d6d2
...@@ -133,17 +133,18 @@ describe('annotator.range-util', () => { ...@@ -133,17 +133,18 @@ describe('annotator.range-util', () => {
selection.collapseToEnd(); selection.collapseToEnd();
selection.extend(testNode, 0); selection.extend(testNode, 0);
const rect = rangeUtil.selectionFocusRect(selection); const rect = rangeUtil.selectionFocusRect(selection);
assert.equal(rect.left, testNode.offsetLeft); assert.approximately(rect.left, testNode.offsetLeft, 1);
assert.equal(rect.top, testNode.offsetTop); assert.approximately(rect.top, testNode.offsetTop, 1);
}); });
it("returns the last line's rect if the selection is forwards", () => { it("returns the last line's rect if the selection is forwards", () => {
selectNode(testNode); selectNode(testNode);
const rect = rangeUtil.selectionFocusRect(selection); const rect = rangeUtil.selectionFocusRect(selection);
assert.equal(rect.left, testNode.offsetLeft); assert.approximately(rect.left, testNode.offsetLeft, 1);
assert.equal( assert.approximately(
rect.top + rect.height, rect.top + rect.height,
testNode.offsetTop + testNode.offsetHeight testNode.offsetTop + testNode.offsetHeight,
1
); );
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment