Add tests for handling overlap of activeElement

If an element receives focus when underneath a
stick element, the window should scroll so the
focused element is revealed.

Includes some changes to the WindowMock API to
allow access to data from Jest spies.
This commit is contained in:
Tom Byers
2019-07-29 09:18:49 +01:00
parent ab6e81a8a6
commit fac116b835
2 changed files with 141 additions and 3 deletions

View File

@@ -224,7 +224,8 @@ class WindowMock {
width: window.innerWidth
};
this.spies = {
document: {}
document: {},
window: {}
};
this._jest = jest;
this._setSpies();
@@ -266,7 +267,7 @@ class WindowMock {
const self = this;
// JSDOM doesn't support .scrollTo
window.scrollTo = function () {
this.spies.window.scrollTo = this._jest.fn(function () {
let y;
// data sent as props in an object
@@ -278,7 +279,9 @@ class WindowMock {
self.scrollTo(y);
};
});
window.scrollTo = this.spies.window.scrollTo;
}