mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-25 10:29:14 -04:00
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:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user