mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-09 19:04:33 -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._setSpies();
|
||||
this._plugJSDOM();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
window.innerHeight = height;
|
||||
|
||||
Reference in New Issue
Block a user