Skip to content

Commit

Permalink
Bump eslint-plugin-mocha to ^10.3.0 (mui#41161)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: siriwatknp <[email protected]>
  • Loading branch information
renovate[bot] and siriwatknp authored Mar 2, 2024
1 parent 8637c07 commit bf80b50
Show file tree
Hide file tree
Showing 57 changed files with 95 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe('useAutocomplete', () => {
let filterOptions;
let getOptionLabel;
let options;

beforeEach(() => {
filterOptions = createFilterOptions({ matchFrom: 'any' });
getOptionLabel = (option) => option.name;
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useInput/useInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>();
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useList/listReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemType> = {
highlightedValue: { v: '1' },
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useList/useList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`, () => {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useMenu/useMenu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useMenu } from './useMenu';

describe('useMenu', () => {
const { render } = createRenderer();

describe('getListboxProps', () => {
it('returns props for root slot', () => {
function TestMenu() {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useMenuButton/useMenuButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const testContext: DropdownContextValue = {

describe('useMenuButton', () => {
const { render } = createRenderer();

describe('getRootProps', () => {
it('returns props for root slot', () => {
function TestMenuButton() {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useMenuItem/useMenuItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useMenuItem } from './useMenuItem';

describe('useMenuItem', () => {
const { render } = createRenderer();

describe('getRootProps', () => {
it('returns props for root slot', () => {
function TestMenuItem() {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useSlider/useSlider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useTab/useTab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useTab } from './useTab';

describe('useTab', () => {
const { render } = createRenderer();

describe('getRootProps', () => {
it('returns props for root slot', () => {
function TestTab() {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useTabPanel/useTabPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/useTabsList/useTabsList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useTabsList } from './useTabsList';

describe('useTabsList', () => {
const { render } = createRenderer();

describe('getRootProps', () => {
it('returns props for root slot', () => {
function TestTabsList() {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-base/src/utils/prepareForSlot.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { prepareForSlot } from './prepareForSlot';

describe('prepareForSlot', () => {
const { render } = createRenderer();

it('should not warn about ownerState', () => {
const ThirdPartyComponent = React.forwardRef<HTMLButtonElement>((props, ref) => {
// @ts-ignore just double checking that it is not defined
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-codemod/src/v5.0.0/jss-to-styled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 10 additions & 0 deletions packages/mui-codemod/src/v5.0.0/jss-to-tss-react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand All @@ -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(
{
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Autocomplete/Autocomplete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ describe('Joy <Autocomplete />', () => {
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(<Autocomplete open options={['one', 'two']} autoFocus />);
const textbox = screen.getByRole('combobox');
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ describe('Joy <Button />', () => {
const button = getByRole('button');
expect(button).to.have.property('disabled', true);
});

it('should disable button when loading is true and disabled is false', () => {
const { getByRole } = render(<Button loading disabled={false} />);

const button = getByRole('button');
expect(button).to.have.property('disabled', true);
});

it('should disable button when loading is false and disabled is true', () => {
const { getByRole } = render(<Button loading={false} disabled />);

Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/Checkbox/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ describe('<Checkbox />', () => {
const { getByTestId } = render(<Checkbox indeterminate checked />);
expect(getByTestId('HorizontalRuleIcon')).not.to.equal(null);
});

it('should render checked icon', () => {
const { getByTestId } = render(<Checkbox checked />);
expect(getByTestId('CheckIcon')).not.to.equal(null);
Expand All @@ -151,6 +152,7 @@ describe('<Checkbox />', () => {
const { getByTestId } = render(<Checkbox uncheckedIcon={<CloseIcon />} />);
expect(getByTestId('CloseIcon')).not.to.equal(null);
});

it('should not render icon', () => {
const { queryByTestId } = render(
<Checkbox disableIcon checked indeterminate uncheckedIcon={<CloseIcon />} />,
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/ChipDelete/ChipDelete.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('<ChipDelete />', () => {
expect(getByRole('button')).to.have.class(classes.colorNeutral);
});
});

describe('Chip onDelete', () => {
it('should call onDelete function when backspace, enter or delete is pressed', () => {
const handleDelete = spy();
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/List/List.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('Joy <List />', () => {
describe('Menu - integration', () => {
const element = document.createElement('div');
element.setAttribute('aria-controls', 'test');

it('should have role="group" inside Menu', () => {
render(
<Menu open anchorEl={() => element}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { applySoftInversion, applySolidInversion } from '@mui/joy/colorInversion

describe('colorInversionUtil', () => {
const { render } = createRenderer();

it('should not throw error using sx prop', () => {
expect(() =>
render(<Box sx={[applySoftInversion('primary'), applySolidInversion('primary')]} />),
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/styles/CssVarsProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('[Joy] CssVarsProvider', () => {
let originalMatchmedia: typeof window.matchMedia;
const { render } = createRenderer();
const storage: Record<string, string> = {};

beforeEach(() => {
originalMatchmedia = window.matchMedia;
// Create mocks of localStorage getItem and setItem functions
Expand All @@ -25,6 +26,7 @@ describe('[Joy] CssVarsProvider', () => {
removeListener: () => {},
}) as unknown as MediaQueryList;
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/styles/ThemeProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import defaultTheme from './defaultTheme';

describe('[Joy] ThemeProvider', () => {
const { render } = createRenderer();

it('can render component without ThemeProvider', () => {
function Text() {
const theme = useTheme();
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/styles/extendTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('extendTheme', () => {

let originalMatchmedia;
const storage = {};

beforeEach(() => {
originalMatchmedia = window.matchMedia;
// Create mocks of localStorage getItem and setItem functions
Expand All @@ -121,6 +122,7 @@ describe('extendTheme', () => {
removeListener: () => {},
});
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/styles/styled.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const toPixel = (val: string | number | undefined) => (typeof val === 'number' ?

describe('[Joy] styled', () => {
const { render } = createRenderer();

it('use defaultTheme given no ThemeProvider', function test() {
if (/jsdom/.test(window.navigator.userAgent)) {
this.skip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('<ButtonBase />', () => {
removeListener: () => {},
}) as unknown as MediaQueryList;
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('<ButtonGroup />', () => {
removeListener: () => {},
}) as unknown as MediaQueryList;
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down
1 change: 1 addition & 0 deletions packages/mui-material-next/src/Chip/Chip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('<Chip />', () => {
removeListener: () => {},
}) as unknown as MediaQueryList;
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-material-next/src/IconButton/IconButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ describe('<IconButton />', () => {

expect(container.firstChild).to.have.class(classes.edgeStart);
});

it('edge="end" should render the right class', () => {
const { container } = render(<IconButton edge="end">book</IconButton>);

expect(container.firstChild).to.have.class(classes.edgeEnd);
});

it('no edge should render the right class', () => {
const { container } = render(<IconButton>book</IconButton>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('<NotchedOutline />', () => {
paddingRight: '8px',
});
});

it('should not set padding (notch) for empty, null or undefined label props', function test() {
if (/jsdom/.test(window.navigator.userAgent)) {
this.skip();
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-material-next/src/Slider/Slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('<Slider />', () => {
removeListener: () => {},
});
});

afterEach(() => {
window.matchMedia = originalMatchmedia;
});
Expand Down Expand Up @@ -724,6 +725,7 @@ describe('<Slider />', () => {
expect(slider).to.have.attribute('aria-valuenow', String(min));
});
});

describe('prop: max', () => {
it('should set the max and aria-valuemax on the input', () => {
const max = 750;
Expand Down
Loading

0 comments on commit bf80b50

Please sign in to comment.