mirror of
https://github.com/joinmarket-webui/jam.git
synced 2026-08-20 13:28:21 +02:00
* build(deps): update jest-watch-typeahead from v0.6.5 to v2.2.2 * build(deps): update jest-websocket-mock to v2.5.0
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
// react-testing-library renders your components to document.body,
|
|
// this adds jest-dom's custom assertions
|
|
import '@testing-library/jest-dom'
|
|
import { WS as WebSocketServer } from 'jest-websocket-mock'
|
|
|
|
global.JM = {
|
|
SETTINGS_STORE_KEY: 'jm-settings',
|
|
THEMES: ['light', 'dark'],
|
|
THEME_ROOT_ATTR: 'data-theme',
|
|
PUBLIC_PATH: '',
|
|
}
|
|
|
|
global.__DEV__ = {}
|
|
|
|
global.__DEV__.addToAppSettings = () => {
|
|
global.localStorage.setItem(
|
|
global.JM.SETTINGS_STORE_KEY,
|
|
JSON.stringify(
|
|
Object.assign({}, global.localStorage.getItem(global.JM.SETTINGS_STORE_KEY) || {}, {
|
|
showOnboarding: false,
|
|
}),
|
|
),
|
|
)
|
|
}
|
|
;(function setupWebsocketServerMock() {
|
|
global.__DEV__.JM_WEBSOCKET_SERVER_MOCK = new WebSocketServer('ws://localhost/jmws', { jsonProtocol: true })
|
|
|
|
afterAll(() => {
|
|
global.__DEV__.JM_WEBSOCKET_SERVER_MOCK.close()
|
|
WebSocketServer.clean()
|
|
})
|
|
})()
|
|
|
|
beforeAll(() => {
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: (query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(), // Deprecated, still needed by @restart/hooks (last check: 2022-05-25)
|
|
removeListener: jest.fn(), // Deprecated
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
}),
|
|
})
|
|
})
|