Skip to content

Commit 14a6365

Browse files
committed
Add matchMedia mock to fix themecomponent tests
1 parent a6921f9 commit 14a6365

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

redisinsight/ui/src/utils/test-utils.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,17 @@ Object.defineProperty(window, 'sessionStorage', { value: sessionStorageMock })
273273
const scrollIntoViewMock = jest.fn()
274274
window.HTMLElement.prototype.scrollIntoView = scrollIntoViewMock
275275

276+
const matchMediaMock = () => ({
277+
matches: false,
278+
addEventListener: jest.fn(),
279+
removeEventListener: jest.fn(),
280+
})
281+
282+
Object.defineProperty(window, 'matchMedia', {
283+
writable: true,
284+
value: jest.fn().mockImplementation(query => matchMediaMock(query)),
285+
})
286+
276287
export const getMswResourceURL = (path: string = '') => RESOURCES_BASE_URL.concat(path)
277288
export const getMswURL = (path: string = '') =>
278289
apiService.defaults.baseURL?.concat(path.startsWith('/') ? path.slice(1) : path) ?? ''

0 commit comments

Comments
 (0)