summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-08-16 17:36:54 +0200
committerPierre Ossman <ossman@cendio.se>2018-08-16 17:36:54 +0200
commit7407c1f4e29a7c7d998edbcc4cbf379edd6b5d76 (patch)
tree1939f4e6f5806bf1dee2902d386b37f28eeb69b7
parentab1ace383e24b2963feb23a59fe50d7aba1c2733 (diff)
downloadnovnc-7407c1f4e29a7c7d998edbcc4cbf379edd6b5d76.tar.gz
Replace bad sinon stub in mouse tests
It screwed up important calls inside the code being tested. Avoid the stub by creating a temporary element with the desired properties.
-rw-r--r--tests/test.mouse.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/test.mouse.js b/tests/test.mouse.js
index dd8046c..9630706 100644
--- a/tests/test.mouse.js
+++ b/tests/test.mouse.js
@@ -5,12 +5,23 @@ import Mouse from '../core/input/mouse.js';
describe('Mouse Event Handling', function() {
"use strict";
- // This function is only used on target (the canvas)
- // and for these tests we can assume that the canvas is 100x100
- // located at coordinates 10x10
- sinon.stub(Element.prototype, 'getBoundingClientRect').returns(
- {left: 10, right: 110, top: 10, bottom: 110, width: 100, height: 100});
- const target = document.createElement('canvas');
+ let target;
+
+ beforeEach(function () {
+ // For these tests we can assume that the canvas is 100x100
+ // located at coordinates 10x10
+ target = document.createElement('canvas');
+ target.style.position = "absolute";
+ target.style.top = "10px";
+ target.style.left = "10px";
+ target.style.width = "100px";
+ target.style.height = "100px";
+ document.body.appendChild(target);
+ });
+ afterEach(function () {
+ document.body.removeChild(target);
+ target = null;
+ });
// The real constructors might not work everywhere we
// want to run these tests