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.
This commit is contained in:
parent
ab1ace383e
commit
7407c1f4e2
|
@ -5,12 +5,23 @@ import Mouse from '../core/input/mouse.js';
|
||||||
describe('Mouse Event Handling', function() {
|
describe('Mouse Event Handling', function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// This function is only used on target (the canvas)
|
let target;
|
||||||
// and for these tests we can assume that the canvas is 100x100
|
|
||||||
|
beforeEach(function () {
|
||||||
|
// For these tests we can assume that the canvas is 100x100
|
||||||
// located at coordinates 10x10
|
// located at coordinates 10x10
|
||||||
sinon.stub(Element.prototype, 'getBoundingClientRect').returns(
|
target = document.createElement('canvas');
|
||||||
{left: 10, right: 110, top: 10, bottom: 110, width: 100, height: 100});
|
target.style.position = "absolute";
|
||||||
const target = document.createElement('canvas');
|
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
|
// The real constructors might not work everywhere we
|
||||||
// want to run these tests
|
// want to run these tests
|
||||||
|
|
Loading…
Reference in New Issue