mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-08 18:54:13 -04:00
Mock IntersectionObserver in Jest setup
This commit is contained in:
parent
3c1073aaef
commit
0c724e3590
@ -119,6 +119,26 @@ Object.defineProperty(window, 'location', {
|
|||||||
value: { reload: jest.fn() },
|
value: { reload: jest.fn() },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user