39 lines
844 B
TypeScript
39 lines
844 B
TypeScript
|
|
import '@testing-library/jest-dom'
|
||
|
|
import { vi } from 'vitest'
|
||
|
|
|
||
|
|
const localStorageMock = {
|
||
|
|
getItem: vi.fn(),
|
||
|
|
setItem: vi.fn(),
|
||
|
|
removeItem: vi.fn(),
|
||
|
|
clear: vi.fn(),
|
||
|
|
key: vi.fn(),
|
||
|
|
length: 0,
|
||
|
|
}
|
||
|
|
vi.stubGlobal('localStorage', localStorageMock)
|
||
|
|
|
||
|
|
Object.defineProperty(window, 'matchMedia', {
|
||
|
|
writable: true,
|
||
|
|
value: vi.fn().mockImplementation(query => ({
|
||
|
|
matches: false,
|
||
|
|
media: query,
|
||
|
|
onchange: null,
|
||
|
|
addListener: vi.fn(),
|
||
|
|
removeListener: vi.fn(),
|
||
|
|
addEventListener: vi.fn(),
|
||
|
|
removeEventListener: vi.fn(),
|
||
|
|
dispatchEvent: vi.fn(),
|
||
|
|
})),
|
||
|
|
})
|
||
|
|
|
||
|
|
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
||
|
|
observe: vi.fn(),
|
||
|
|
unobserve: vi.fn(),
|
||
|
|
disconnect: vi.fn(),
|
||
|
|
}))
|
||
|
|
|
||
|
|
global.MutationObserver = vi.fn().mockImplementation(() => ({
|
||
|
|
observe: vi.fn(),
|
||
|
|
disconnect: vi.fn(),
|
||
|
|
takeRecords: vi.fn(),
|
||
|
|
}))
|