diff --git a/docs/data/material/components/use-media-query/use-media-query.md b/docs/data/material/components/use-media-query/use-media-query.md index 982c854e4ff9d6..fd618904d9b36b 100644 --- a/docs/data/material/components/use-media-query/use-media-query.md +++ b/docs/data/material/components/use-media-query/use-media-query.md @@ -78,8 +78,8 @@ function createMatchMedia(width) { matches: mediaQuery.match(query, { width, }), - addListener: () => {}, - removeListener: () => {}, + addEventListener: () => {}, + removeEventListener: () => {}, }); } diff --git a/packages-internal/test-utils/src/describeConformance.tsx b/packages-internal/test-utils/src/describeConformance.tsx index a194137de2a21b..3c2177b299de8a 100644 --- a/packages-internal/test-utils/src/describeConformance.tsx +++ b/packages-internal/test-utils/src/describeConformance.tsx @@ -1034,8 +1034,11 @@ function describeConformance( }); window.matchMedia = () => ({ + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }) as unknown as MediaQueryList; }); afterEach(() => { diff --git a/packages/mui-joy/src/styles/CssVarsProvider.test.tsx b/packages/mui-joy/src/styles/CssVarsProvider.test.tsx index fcbdb5349589d8..9bb17ff8964bce 100644 --- a/packages/mui-joy/src/styles/CssVarsProvider.test.tsx +++ b/packages/mui-joy/src/styles/CssVarsProvider.test.tsx @@ -22,8 +22,11 @@ describe('[Joy] CssVarsProvider', () => { }); window.matchMedia = () => ({ + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }) as unknown as MediaQueryList; }); diff --git a/packages/mui-joy/src/styles/extendTheme.test.js b/packages/mui-joy/src/styles/extendTheme.test.js index a3e6728ad1a44d..9bf3097075bac3 100644 --- a/packages/mui-joy/src/styles/extendTheme.test.js +++ b/packages/mui-joy/src/styles/extendTheme.test.js @@ -215,8 +215,11 @@ describe('extendTheme', () => { configurable: true, }); window.matchMedia = () => ({ + // Keep mocking legacy methods because older code might still use them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }); }); diff --git a/packages/mui-material/src/styles/ThemeProvider.test.tsx b/packages/mui-material/src/styles/ThemeProvider.test.tsx index 5f6f58d31d522e..d21e01db663f23 100644 --- a/packages/mui-material/src/styles/ThemeProvider.test.tsx +++ b/packages/mui-material/src/styles/ThemeProvider.test.tsx @@ -23,8 +23,11 @@ describe('ThemeProvider', () => { }); window.matchMedia = () => ({ + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }) as unknown as MediaQueryList; }); diff --git a/packages/mui-material/src/styles/ThemeProviderWithVars.test.js b/packages/mui-material/src/styles/ThemeProviderWithVars.test.js index 9629a94028f37b..6311728b415ca3 100644 --- a/packages/mui-material/src/styles/ThemeProviderWithVars.test.js +++ b/packages/mui-material/src/styles/ThemeProviderWithVars.test.js @@ -22,8 +22,11 @@ describe('[Material UI] ThemeProviderWithVars', () => { configurable: true, }); window.matchMedia = () => ({ + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }); }); diff --git a/packages/mui-material/src/styles/extendTheme.test.js b/packages/mui-material/src/styles/extendTheme.test.js index 2d4b0dd0de8d22..00bd6111455fce 100644 --- a/packages/mui-material/src/styles/extendTheme.test.js +++ b/packages/mui-material/src/styles/extendTheme.test.js @@ -24,8 +24,11 @@ describe('extendTheme', () => { configurable: true, }); window.matchMedia = () => ({ + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }); }); diff --git a/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.test.js b/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.test.js index f081fe25f2200e..2b29e22c83a2fe 100644 --- a/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.test.js +++ b/packages/mui-system/src/InitColorSchemeScript/InitColorSchemeScript.test.js @@ -14,8 +14,8 @@ describe('InitColorSchemeScript', () => { let storage = {}; const createMatchMedia = (matches) => () => ({ matches, - addListener: () => {}, - removeListener: () => {}, + addEventListener: () => {}, + removeEventListener: () => {}, }); beforeEach(() => { diff --git a/packages/mui-system/src/cssVars/createCssVarsProvider.test.js b/packages/mui-system/src/cssVars/createCssVarsProvider.test.js index 2431242d75fe5f..4accde568ba8ca 100644 --- a/packages/mui-system/src/cssVars/createCssVarsProvider.test.js +++ b/packages/mui-system/src/cssVars/createCssVarsProvider.test.js @@ -17,8 +17,11 @@ describe('createCssVarsProvider', () => { let storage = {}; const createMatchMedia = (matches) => () => ({ matches, + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }); beforeEach(() => { diff --git a/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js b/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js index d120daa8bc3d00..a0d75139ea55e6 100644 --- a/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js +++ b/packages/mui-system/src/cssVars/useCurrentColorScheme.test.js @@ -18,10 +18,15 @@ describe('useCurrentColorScheme', () => { const createMatchMedia = (matches) => () => ({ matches, + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: (listener) => { trigger = listener; }, + addEventListener: (listener) => { + trigger = listener; + }, removeListener: () => {}, + removeEventListener: () => {}, }); before(() => { diff --git a/test/integration/mui-system/theme-scoping.test.tsx b/test/integration/mui-system/theme-scoping.test.tsx index 83e409d7288fe2..fe8040c584e093 100644 --- a/test/integration/mui-system/theme-scoping.test.tsx +++ b/test/integration/mui-system/theme-scoping.test.tsx @@ -68,8 +68,11 @@ describe('Multiple nested theme providers', () => { let storage: Record = {}; const createMatchMedia = (matches: boolean) => () => ({ matches, + // Keep mocking legacy methods because @mui/material v5 still uses them addListener: () => {}, + addEventListener: () => {}, removeListener: () => {}, + removeEventListener: () => {}, }); beforeEach(() => {