mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
32 lines
866 B
TypeScript
32 lines
866 B
TypeScript
import { jest } from '@jest/globals'
|
|
|
|
/* global mocks for jsdom */
|
|
const mock = () => {
|
|
let storage: { [key: string]: string } = {}
|
|
return {
|
|
getItem: (key: string) => (key in storage ? storage[key] : null),
|
|
setItem: (key: string, value: string) => (storage[key] = value || ''),
|
|
removeItem: (key: string) => delete storage[key],
|
|
clear: () => (storage = {}),
|
|
}
|
|
}
|
|
|
|
Object.defineProperty(window, 'localStorage', { value: mock() })
|
|
Object.defineProperty(window, 'sessionStorage', { value: mock() })
|
|
Object.defineProperty(window, 'getComputedStyle', {
|
|
value: () => ['-webkit-appearance'],
|
|
})
|
|
|
|
Object.defineProperty(document.body.style, 'transform', {
|
|
value: () => {
|
|
return {
|
|
enumerable: true,
|
|
configurable: true,
|
|
}
|
|
},
|
|
})
|
|
|
|
HTMLCanvasElement.prototype.getContext = <
|
|
typeof HTMLCanvasElement.prototype.getContext
|
|
>jest.fn()
|