REFACTOR: Remove `window.sinon` and `window.MouseTrap` from tests (#11092)

Also allow us to reset mousetrap in a teardown method.
This commit is contained in:
Robin Ward 2020-11-02 05:44:52 -05:00 committed by GitHub
parent b73234b75c
commit 88c2cbb6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -118,6 +118,8 @@ export default {
},
teardown() {
this.keyTrapper.reset();
this.keyTrapper = null;
this.container = null;
},

View File

@ -76,7 +76,7 @@ export default function setupTests(app, container) {
dropFrom: "2.6.0",
}
);
return window.sinon;
return sinon;
},
});
Object.defineProperty(window, "exists", {
@ -121,7 +121,8 @@ export default function setupTests(app, container) {
const error =
"Unhandled request in test environment: " + path + " (" + verb + ")";
window.console.error(error);
// eslint-disable-next-line no-console
console.error(error);
throw new Error(error);
};
@ -144,16 +145,16 @@ export default function setupTests(app, container) {
PreloadStore.reset();
window.sinon.stub(ScrollingDOMMethods, "screenNotFull");
window.sinon.stub(ScrollingDOMMethods, "bindOnScroll");
window.sinon.stub(ScrollingDOMMethods, "unbindOnScroll");
sinon.stub(ScrollingDOMMethods, "screenNotFull");
sinon.stub(ScrollingDOMMethods, "bindOnScroll");
sinon.stub(ScrollingDOMMethods, "unbindOnScroll");
// Unless we ever need to test this, let's leave it off.
$.fn.autocomplete = function () {};
});
QUnit.testDone(function () {
window.sinon.restore();
sinon.restore();
// Destroy any modals
$(".modal-backdrop").remove();
@ -166,7 +167,6 @@ export default function setupTests(app, container) {
MessageBus.unsubscribe("*");
server = null;
window.Mousetrap.reset();
});
// Load ES6 tests