chore: improve test utils
This commit is contained in:
+7
-5
@@ -30,13 +30,12 @@ function mockHTMLElementOffset() {
|
||||
});
|
||||
}
|
||||
|
||||
function mockScrollIntoView() {
|
||||
Element.prototype.scrollIntoView = function() {};
|
||||
export function mockScrollIntoView() {
|
||||
const fn = jest.fn();
|
||||
Element.prototype.scrollIntoView = fn;
|
||||
return fn;
|
||||
}
|
||||
|
||||
mockScrollIntoView();
|
||||
mockHTMLElementOffset();
|
||||
|
||||
export function mockGetBoundingClientRect(
|
||||
rect: ClientRect | DOMRect
|
||||
): Function {
|
||||
@@ -53,3 +52,6 @@ export function mockScrollTop(value: number) {
|
||||
Object.defineProperty(window, 'scrollTop', { value, writable: true });
|
||||
trigger(window, 'scroll');
|
||||
}
|
||||
|
||||
mockScrollIntoView();
|
||||
mockHTMLElementOffset();
|
||||
|
||||
Reference in New Issue
Block a user