diff --git a/package.json b/package.json index fbe305bc0eb4d3..28f474cdab7a85 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "eslint-plugin-import": "^2.29.1", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-material-ui": "workspace:^", - "eslint-plugin-mocha": "^10.2.0", + "eslint-plugin-mocha": "^10.3.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "fast-glob": "^3.3.2", diff --git a/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js b/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js index 0386731e59eeb8..264f0ee8f67ce2 100644 --- a/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js +++ b/packages/mui-base/src/useAutocomplete/useAutocomplete.test.js @@ -118,6 +118,7 @@ describe('useAutocomplete', () => { let filterOptions; let getOptionLabel; let options; + beforeEach(() => { filterOptions = createFilterOptions({ matchFrom: 'any' }); getOptionLabel = (option) => option.name; diff --git a/packages/mui-base/src/useInput/useInput.test.tsx b/packages/mui-base/src/useInput/useInput.test.tsx index a2ff388030c95a..9ece7ed65a20ad 100644 --- a/packages/mui-base/src/useInput/useInput.test.tsx +++ b/packages/mui-base/src/useInput/useInput.test.tsx @@ -7,6 +7,7 @@ import { UseInputParameters } from './useInput.types'; describe('useInput', () => { const { render } = createRenderer(); + describe('params: inputRef', () => { it('should be able to attach input ref passed through params', () => { const inputRef = React.createRef(); diff --git a/packages/mui-base/src/useList/listReducer.test.ts b/packages/mui-base/src/useList/listReducer.test.ts index 873be0f0f7430e..1a60ac1f74c42f 100644 --- a/packages/mui-base/src/useList/listReducer.test.ts +++ b/packages/mui-base/src/useList/listReducer.test.ts @@ -948,6 +948,7 @@ describe('listReducer', () => { describe('using custom item comparer', () => { type ItemType = { v: string }; + it('keeps the highlighted value if it is present among the new items', () => { const state: ListState = { highlightedValue: { v: '1' }, diff --git a/packages/mui-base/src/useList/useList.test.tsx b/packages/mui-base/src/useList/useList.test.tsx index 7e8ffa6f1ce2fb..1c225a474917bb 100644 --- a/packages/mui-base/src/useList/useList.test.tsx +++ b/packages/mui-base/src/useList/useList.test.tsx @@ -6,6 +6,7 @@ import { useList } from './useList'; describe('useList', () => { const { render } = createRenderer(); + describe('preventing default behavior on keyDown', () => { ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown', 'Enter', ' '].forEach((key) => it(`prevents default behavior when ${key} is pressed in activeDescendant focus management mode`, () => { diff --git a/packages/mui-base/src/useMenu/useMenu.test.js b/packages/mui-base/src/useMenu/useMenu.test.js index d3973de7d06f3f..bca1913869d9a2 100644 --- a/packages/mui-base/src/useMenu/useMenu.test.js +++ b/packages/mui-base/src/useMenu/useMenu.test.js @@ -7,6 +7,7 @@ import { useMenu } from './useMenu'; describe('useMenu', () => { const { render } = createRenderer(); + describe('getListboxProps', () => { it('returns props for root slot', () => { function TestMenu() { diff --git a/packages/mui-base/src/useMenuButton/useMenuButton.test.tsx b/packages/mui-base/src/useMenuButton/useMenuButton.test.tsx index 9bf81af45f0a93..b58885e739495c 100644 --- a/packages/mui-base/src/useMenuButton/useMenuButton.test.tsx +++ b/packages/mui-base/src/useMenuButton/useMenuButton.test.tsx @@ -16,6 +16,7 @@ const testContext: DropdownContextValue = { describe('useMenuButton', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('returns props for root slot', () => { function TestMenuButton() { diff --git a/packages/mui-base/src/useMenuItem/useMenuItem.test.tsx b/packages/mui-base/src/useMenuItem/useMenuItem.test.tsx index a599bfb52ae110..81b8e9435b303e 100644 --- a/packages/mui-base/src/useMenuItem/useMenuItem.test.tsx +++ b/packages/mui-base/src/useMenuItem/useMenuItem.test.tsx @@ -7,6 +7,7 @@ import { useMenuItem } from './useMenuItem'; describe('useMenuItem', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('returns props for root slot', () => { function TestMenuItem() { diff --git a/packages/mui-base/src/useSlider/useSlider.test.js b/packages/mui-base/src/useSlider/useSlider.test.js index b717f0e934b57e..c7b964335e184e 100644 --- a/packages/mui-base/src/useSlider/useSlider.test.js +++ b/packages/mui-base/src/useSlider/useSlider.test.js @@ -6,6 +6,7 @@ import { useSlider } from './useSlider'; describe('useSlider', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('forwards external props including event handlers', () => { const rootRef = React.createRef(); diff --git a/packages/mui-base/src/useTab/useTab.test.tsx b/packages/mui-base/src/useTab/useTab.test.tsx index c20252849006af..047c739c137628 100644 --- a/packages/mui-base/src/useTab/useTab.test.tsx +++ b/packages/mui-base/src/useTab/useTab.test.tsx @@ -8,6 +8,7 @@ import { useTab } from './useTab'; describe('useTab', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('returns props for root slot', () => { function TestTab() { diff --git a/packages/mui-base/src/useTabPanel/useTabPanel.test.js b/packages/mui-base/src/useTabPanel/useTabPanel.test.js index e94b8bd283bbb9..c516c2ce9b860d 100644 --- a/packages/mui-base/src/useTabPanel/useTabPanel.test.js +++ b/packages/mui-base/src/useTabPanel/useTabPanel.test.js @@ -9,6 +9,7 @@ import { useTabPanel } from './useTabPanel'; describe('useTabPanel', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('returns props for root slot', () => { const rootRef = React.createRef(); diff --git a/packages/mui-base/src/useTabsList/useTabsList.test.tsx b/packages/mui-base/src/useTabsList/useTabsList.test.tsx index dc9d4630aff8cc..02fe3b020c6b1b 100644 --- a/packages/mui-base/src/useTabsList/useTabsList.test.tsx +++ b/packages/mui-base/src/useTabsList/useTabsList.test.tsx @@ -7,6 +7,7 @@ import { useTabsList } from './useTabsList'; describe('useTabsList', () => { const { render } = createRenderer(); + describe('getRootProps', () => { it('returns props for root slot', () => { function TestTabsList() { diff --git a/packages/mui-base/src/utils/prepareForSlot.test.tsx b/packages/mui-base/src/utils/prepareForSlot.test.tsx index 7b26144b2e6e79..fd6e36368502bc 100644 --- a/packages/mui-base/src/utils/prepareForSlot.test.tsx +++ b/packages/mui-base/src/utils/prepareForSlot.test.tsx @@ -6,6 +6,7 @@ import { prepareForSlot } from './prepareForSlot'; describe('prepareForSlot', () => { const { render } = createRenderer(); + it('should not warn about ownerState', () => { const ThirdPartyComponent = React.forwardRef((props, ref) => { // @ts-ignore just double checking that it is not defined diff --git a/packages/mui-codemod/src/v5.0.0/jss-to-styled.test.js b/packages/mui-codemod/src/v5.0.0/jss-to-styled.test.js index 932ff64687c877..2cbbd5fac8c9ba 100644 --- a/packages/mui-codemod/src/v5.0.0/jss-to-styled.test.js +++ b/packages/mui-codemod/src/v5.0.0/jss-to-styled.test.js @@ -24,6 +24,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-styled.test/Anonymous.expected.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + describe('first', () => { it('transforms as needed', () => { const actual = transform( @@ -534,6 +535,7 @@ describe('@mui/codemod', () => { expect(actual).to.equal(expected, 'The transformed version should be correct'); }); }); + describe('bugs - #28317 export class declaration', () => { it('transforms as needed', () => { const actual = transform( diff --git a/packages/mui-codemod/src/v5.0.0/jss-to-tss-react.test.js b/packages/mui-codemod/src/v5.0.0/jss-to-tss-react.test.js index 12a4ce281419fd..b0c6848a4b5fae 100644 --- a/packages/mui-codemod/src/v5.0.0/jss-to-tss-react.test.js +++ b/packages/mui-codemod/src/v5.0.0/jss-to-tss-react.test.js @@ -25,6 +25,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-from-material-ui-core-styles.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('should be idempotent', () => { const actual = transform( { @@ -40,6 +41,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-from-material-ui-core-styles.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms @material-ui/core makeStyles to use tss-react', () => { const actual = transform( { @@ -53,6 +55,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-from-material-ui-core.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('adds todo comments for scenarios that are not supported', () => { const actual = transform( { @@ -66,6 +69,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-todo-comments.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms makeStyles with style rules returned by function to use tss-react', () => { const actual = transform( { @@ -79,6 +83,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-mixins-pattern.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms @mui/styles makeStyles to use tss-react', () => { const actual = transform( { @@ -92,6 +97,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-from-mui-styles.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms @mui/styles/makeStyles to use tss-react', () => { const actual = transform( { @@ -105,6 +111,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-from-mui-styles-makeStyles.js'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms typescript makeStyles with nested selectors to use tss-react', () => { const actual = transform( { @@ -118,6 +125,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-typescript.tsx'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms typescript makeStyles example in docs to use tss-react', () => { const actual = transform( { @@ -131,6 +139,7 @@ describe('@mui/codemod', () => { const expected = read('./jss-to-tss-react.test/expected-typescript-docs-example.tsx'); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms typescript makeStyles advanced example in docs with params to use tss-react', () => { const actual = transform( { @@ -148,6 +157,7 @@ describe('@mui/codemod', () => { ); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); + it('transforms withStyles to use tss-react', () => { const actual = transform( { diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx index 09b874caa4c560..44b0ce311cb53f 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx @@ -1323,6 +1323,7 @@ describe('Joy ', () => { checkHighlightIs(autocompleteListbox, 'six'); expect(autocompleteListbox.scrollTop).to.greaterThan(0); }); + it('should keep focus on selected option and not reset to top option when options updated', () => { const { setProps } = render(); const textbox = screen.getByRole('combobox'); diff --git a/packages/mui-joy/src/Button/Button.test.tsx b/packages/mui-joy/src/Button/Button.test.tsx index 57bf78208efa38..590e7a7af67666 100644 --- a/packages/mui-joy/src/Button/Button.test.tsx +++ b/packages/mui-joy/src/Button/Button.test.tsx @@ -112,12 +112,14 @@ describe('Joy