mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-05 03:26:11 -06:00
Mock IntersectionObserver in Jest setup
This commit is contained in:
@@ -121,6 +121,26 @@ if (!URL.revokeObjectURL) {
|
|||||||
}
|
}
|
||||||
Object.defineProperty(window, 'ResizeObserver', { value: mock() })
|
Object.defineProperty(window, 'ResizeObserver', { value: mock() })
|
||||||
|
|
||||||
|
if (typeof IntersectionObserver === 'undefined') {
|
||||||
|
class MockIntersectionObserver {
|
||||||
|
constructor(
|
||||||
|
public callback: IntersectionObserverCallback,
|
||||||
|
public options?: IntersectionObserverInit
|
||||||
|
) {}
|
||||||
|
|
||||||
|
observe = jest.fn()
|
||||||
|
unobserve = jest.fn()
|
||||||
|
disconnect = jest.fn()
|
||||||
|
takeRecords = jest.fn()
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.defineProperty(window, 'IntersectionObserver', {
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
value: MockIntersectionObserver,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
HTMLCanvasElement.prototype.getContext = <
|
HTMLCanvasElement.prototype.getContext = <
|
||||||
typeof HTMLCanvasElement.prototype.getContext
|
typeof HTMLCanvasElement.prototype.getContext
|
||||||
>jest.fn()
|
>jest.fn()
|
||||||
|
|||||||
Reference in New Issue
Block a user