Skip to content

Commit a796e16

Browse files
authored
Merge pull request #2627 from RedisInsight/bugfix/RI-4893_system_theme
Add matchMedia mock to fix themecomponent tests
2 parents 6648458 + 14a6365 commit a796e16

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)