Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Dec 10, 2024
1 parent 3830ac3 commit 3b02efa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react/src/Header/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react'
// import { createRef } from 'react'
import './matchMedia.mock'
import { Header } from './Header'
import '@testing-library/jest-dom'

Expand Down
15 changes: 15 additions & 0 deletions packages/react/src/Header/matchMedia.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Sourced from https://jestjs.io/docs/29.4/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // deprecated
removeListener: jest.fn(), // deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
})

0 comments on commit 3b02efa

Please sign in to comment.