mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
Make helper plug gap in JSDOM's DOM API
Errors fired from JSDOM showed it doesn't support `window.scrollTo` (or `window.scroll` for that matter). This stubs it, to the extent that our use (jQuery really) of it works.
This commit is contained in:
@@ -228,6 +228,7 @@ class WindowMock {
|
|||||||
};
|
};
|
||||||
this._jest = jest;
|
this._jest = jest;
|
||||||
this._setSpies();
|
this._setSpies();
|
||||||
|
this._plugJSDOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
get top () {
|
get top () {
|
||||||
@@ -260,6 +261,27 @@ class WindowMock {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_plugJSDOM () {
|
||||||
|
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
// JSDOM doesn't support .scrollTo
|
||||||
|
window.scrollTo = function () {
|
||||||
|
let y;
|
||||||
|
|
||||||
|
// data sent as props in an object
|
||||||
|
if (arguments.length === 1) {
|
||||||
|
y = arguments[0].y;
|
||||||
|
} else {
|
||||||
|
y = arguments[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.scrollTo(y);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
setHeightTo (height) {
|
setHeightTo (height) {
|
||||||
|
|
||||||
window.innerHeight = height;
|
window.innerHeight = height;
|
||||||
|
|||||||
Reference in New Issue
Block a user