Skip to content

Commit

Permalink
Update packages to use test-utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Sep 19, 2023
1 parent b442052 commit c63919c
Show file tree
Hide file tree
Showing 345 changed files with 660 additions and 363 deletions.
2 changes: 1 addition & 1 deletion docs/src/modules/components/HighlightedCode.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer } from 'test/utils';
import { createRenderer } from '@mui-internal/test-utilities';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import { getDesignTokens } from 'docs/src/modules/brandingTheme';
import HighlightedCode from 'docs/src/modules/components/HighlightedCode';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const ruleTester = new eslint.RuleTester({
});
ruleTester.run('disallow-active-element-as-key-event-target', rule, {
valid: [
"import { fireEvent } from 'test/utils';\nfireEvent.keyDown(getByRole('button'), { key: ' ' })",
"import { fireEvent } from 'test/utils';\nfireEvent.keyDown(document.body, { key: 'Esc' })",
"import { fireEvent } from 'test/utils';\nfireEvent.keyUp(document.body, { key: 'Tab' })",
"import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyDown(getByRole('button'), { key: ' ' })",
"import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyDown(document.body, { key: 'Esc' })",
"import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyUp(document.body, { key: 'Tab' })",
],
invalid: [
{
code: "import { fireEvent } from 'test/utils';\nfireEvent.keyUp(document.activeElement, { key: 'LeftArrow' })",
code: "import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyUp(document.activeElement, { key: 'LeftArrow' })",
errors: [
{
message:
Expand All @@ -23,7 +23,7 @@ ruleTester.run('disallow-active-element-as-key-event-target', rule, {
],
},
{
code: "import { fireEvent } from 'test/utils';\nfireEvent.keyDown(document.activeElement, { key: 'DownArrow' })",
code: "import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyDown(document.activeElement, { key: 'DownArrow' })",
errors: [
{
message:
Expand Down Expand Up @@ -54,7 +54,7 @@ ruleTester.run('disallow-active-element-as-key-event-target', rule, {
},
{
// test non-null assertion operator
code: "import { fireEvent } from 'test/utils';\nfireEvent.keyUp(document.activeElement!, { key: 'LeftArrow' })",
code: "import { fireEvent } from '@mui-internal/test-utilities';\nfireEvent.keyUp(document.activeElement!, { key: 'LeftArrow' })",
errors: [
{
message:
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
},
"devDependencies": {
"@mui/material": "^5.14.10",
"@mui-internal/test-utilities": "^1.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/chai": "^4.3.5",
Expand All @@ -63,8 +64,7 @@
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sinon": "^15.2.0",
"test": "^5.0.0"
"sinon": "^15.2.0"
},
"peerDependencies": {
"@types/react": "^17.0.0 || ^18.0.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/Badge/Badge.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createRenderer, createMount, describeConformanceUnstyled } from 'test/utils';
import {
createRenderer,
createMount,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { Badge, badgeClasses as classes } from '@mui/base/Badge';

describe('<Badge />', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createRenderer,
describeConformanceUnstyled,
fireEvent,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { expect } from 'chai';
import { spy } from 'sinon';
import { Button, buttonClasses } from '@mui/base/Button';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { expect } from 'chai';
import { spy } from 'sinon';
import { act, createRenderer, fireEvent, fireDiscreteEvent, screen } from 'test/utils';
import {
act,
createRenderer,
fireEvent,
fireDiscreteEvent,
screen,
} from '@mui-internal/test-utilities';
import { Portal } from '@mui/base/Portal';
import { ClickAwayListener } from '@mui/base/ClickAwayListener';

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Dropdown/Dropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { act, createRenderer } from 'test/utils';
import { act, createRenderer } from '@mui-internal/test-utilities';
import { Dropdown } from '@mui/base/Dropdown';
import { DropdownContext } from '@mui/base/useDropdown';
import { MenuButton } from '@mui/base/MenuButton';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/FocusTrap/FocusTrap.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { expect } from 'chai';
import { act, createRenderer, screen } from 'test/utils';
import { act, createRenderer, screen } from '@mui-internal/test-utilities';
import { FocusTrap } from '@mui/base/FocusTrap';
import { Portal } from '@mui/base/Portal';

Expand Down
7 changes: 6 additions & 1 deletion packages/mui-base/src/FormControl/FormControl.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { createMount, createRenderer, describeConformanceUnstyled, fireEvent } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
fireEvent,
} from '@mui-internal/test-utilities';
import { FormControl, formControlClasses, useFormControlContext } from '@mui/base/FormControl';

describe('<FormControl />', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Input/Input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
describeConformanceUnstyled,
fireEvent,
screen,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { expect } from 'chai';
import { spy } from 'sinon';
import { Input, inputClasses } from '@mui/base/Input';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
describeConformanceUnstyled,
fireEvent,
act,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { Menu, menuClasses } from '@mui/base/Menu';
import { MenuItem } from '@mui/base/MenuItem';
import { DropdownContext, DropdownContextValue } from '@mui/base/useDropdown';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/MenuButton/MenuButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
createRenderer,
describeConformanceUnstyled,
fireEvent,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { MenuButton, menuButtonClasses } from '@mui/base/MenuButton';
import { DropdownContext, DropdownContextValue, DropdownActionTypes } from '@mui/base/useDropdown';

Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/MenuItem/MenuItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { MenuItem, menuItemClasses } from '@mui/base/MenuItem';
import { MenuProvider } from '@mui/base/useMenu';

Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as React from 'react';
import { expect } from 'chai';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { Modal, modalClasses as classes, ModalRootSlotProps } from '@mui/base/Modal';

describe('<Modal />', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/NoSsr/NoSsr.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer } from 'test/utils';
import { createRenderer } from '@mui-internal/test-utilities';
import { NoSsr } from '@mui/base/NoSsr';

describe('<NoSsr />', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/Option/Option.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { Option, optionClasses } from '@mui/base/Option';
import { SelectProvider } from '../useSelect/SelectProvider';

Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/OptionGroup/OptionGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { OptionGroup, optionGroupClasses } from '@mui/base/OptionGroup';

describe('<OptionGroup />', () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/mui-base/src/Popper/Popper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, createMount, describeConformanceUnstyled, screen } from 'test/utils';
import {
createRenderer,
createMount,
describeConformanceUnstyled,
screen,
} from '@mui-internal/test-utilities';
import { Popper, popperClasses } from '@mui/base/Popper';

describe('<Popper />', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Portal/Portal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { createRenderer } from 'test/utils';
import { createRenderer } from '@mui-internal/test-utilities';
import { Portal, PortalProps } from '@mui/base/Portal';

describe('<Portal />', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
userEvent,
act,
screen,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { Select, SelectListboxSlotProps, selectClasses } from '@mui/base/Select';
import { useOption, SelectOption } from '@mui/base/useOption';
import { Option, OptionProps, optionClasses } from '@mui/base/Option';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Slider/Slider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
describeConformanceUnstyled,
fireEvent,
screen,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import {
Slider,
sliderClasses as classes,
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Snackbar/Snackbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
createMount,
describeConformanceUnstyled,
fireEvent,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { Snackbar, snackbarClasses as classes } from '@mui/base/Snackbar';

describe('<Snackbar />', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/Switch/Switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { expect } from 'chai';
import { Switch, SwitchOwnerState, switchClasses } from '@mui/base/Switch';

Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/Tab/Tab.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { Tab, tabClasses } from '@mui/base/Tab';
import { TabsListProvider, TabsListProviderValue } from '../useTabsList';
import { TabsContext } from '../Tabs';
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/TabPanel/TabPanel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { TabPanel, tabPanelClasses } from '@mui/base/TabPanel';
import { TabsProvider, TabsProviderValue } from '../useTabs';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import PropTypes from 'prop-types';
import { describeConformanceUnstyled, fireEvent, createRenderer, createMount } from 'test/utils';
import {
describeConformanceUnstyled,
fireEvent,
createRenderer,
createMount,
} from '@mui-internal/test-utilities';
import TableFooter from '@mui/material/TableFooter';
import TableRow from '@mui/material/TableRow';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Tabs/Tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
fireEvent,
screen,
createMount,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { Tab } from '@mui/base/Tab';
import { Tabs, tabsClasses as classes, TabsProps } from '@mui/base/Tabs';
import { TabsList } from '@mui/base/TabsList';
Expand Down
6 changes: 5 additions & 1 deletion packages/mui-base/src/TabsList/TabsList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as React from 'react';
import { createMount, createRenderer, describeConformanceUnstyled } from 'test/utils';
import {
createMount,
createRenderer,
describeConformanceUnstyled,
} from '@mui-internal/test-utilities';
import { TabsContext } from '@mui/base/Tabs';
import { TabsList, tabsListClasses } from '@mui/base/TabsList';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
createRenderer,
fireEvent,
strictModeDoubleLoggingSuppressed,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import { TextareaAutosize } from '@mui/base/TextareaAutosize';

function getStyleValue(value: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
createRenderer,
describeConformanceUnstyled,
fireEvent,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import {
Unstable_NumberInput as NumberInput,
numberInputClasses,
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Unstable_Popup/Popup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
describeConformanceUnstyled,
screen,
fireEvent,
} from 'test/utils';
} from '@mui-internal/test-utilities';
import {
Unstable_Popup as Popup,
popupClasses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import userEvent from '@testing-library/user-event';
import { createRenderer, screen } from 'test/utils';
import { createRenderer, screen } from '@mui-internal/test-utilities';
import {
unstable_useNumberInput as useNumberInput,
UseNumberInputParameters,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, screen, ErrorBoundary, act, fireEvent } from 'test/utils';
import {
createRenderer,
screen,
ErrorBoundary,
act,
fireEvent,
} from '@mui-internal/test-utilities';
import { spy } from 'sinon';
import { useAutocomplete, createFilterOptions } from '@mui/base/useAutocomplete';

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useButton/useButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { act, createRenderer, fireEvent } from 'test/utils';
import { act, createRenderer, fireEvent } from '@mui-internal/test-utilities';
import { expect } from 'chai';
import { spy } from 'sinon';
import { useButton } from '@mui/base/useButton';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useInput/useInput.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { act, createRenderer } from 'test/utils';
import { act, createRenderer } from '@mui-internal/test-utilities';
import { expect } from 'chai';
import { spy } from 'sinon';
import { useInput } from './useInput';
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useList/useList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { expect } from 'chai';
import { SinonSpy, spy } from 'sinon';
import { createRenderer, createEvent, fireEvent } from 'test/utils';
import { createRenderer, createEvent, fireEvent } from '@mui-internal/test-utilities';
import { useList } from './useList';

describe('useList', () => {
Expand Down
Loading

0 comments on commit c63919c

Please sign in to comment.