Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Remove createMount test util #42849

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/mui-base/src/Badge/Badge.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';
import { createRenderer, createMount } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { Badge, badgeClasses as classes } from '@mui/base/Badge';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Badge />', () => {
const { render } = createRenderer();
const mount = createMount();

describeConformanceUnstyled(
<Badge>
Expand All @@ -15,7 +14,6 @@ describe('<Badge />', () => {
classes,
inheritComponent: 'span',
render,
mount,
refInstanceof: window.HTMLSpanElement,
testComponentPropWith: 'div',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import * as React from 'react';
import { act, createMount, createRenderer, fireEvent } from '@mui-internal/test-utils';
import { act, createRenderer, fireEvent } from '@mui-internal/test-utils';
import { expect } from 'chai';
import { spy } from 'sinon';
import { Button, buttonClasses } from '@mui/base/Button';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Button />', () => {
const mount = createMount();
const { render, renderToString } = createRenderer();

describeConformanceUnstyled(<Button />, () => ({
inheritComponent: 'button',
render,
mount,
refInstanceof: window.HTMLButtonElement,
testComponentPropWith: 'span',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/FormControl/FormControl.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { createMount, createRenderer, fireEvent } from '@mui-internal/test-utils';
import { createRenderer, fireEvent } from '@mui-internal/test-utils';
import { FormControl, formControlClasses, useFormControlContext } from '@mui/base/FormControl';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<FormControl />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<FormControl />, () => ({
inheritComponent: 'div',
render,
mount,
refInstanceof: window.HTMLDivElement,
testComponentPropWith: 'div',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Input/Input.test.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { createMount, createRenderer, fireEvent, screen, act } from '@mui-internal/test-utils';
import { createRenderer, fireEvent, screen, act } from '@mui-internal/test-utils';
import { expect } from 'chai';
import { spy } from 'sinon';
import { Input, inputClasses, InputOwnerState } from '@mui/base/Input';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Input />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<Input />, () => ({
inheritComponent: 'div',
render,
mount,
refInstanceof: window.HTMLDivElement,
testComponentPropWith: 'div',
slots: {
Expand Down
8 changes: 0 additions & 8 deletions packages/mui-base/src/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import {
createMount,
createRenderer,
fireEvent,
act,
Expand All @@ -27,7 +26,6 @@ const testContext: DropdownContextValue = {
};

describe('<Menu />', () => {
const mount = createMount();
const { render: internalRender } = createRenderer();

async function render(
Expand All @@ -46,12 +44,6 @@ describe('<Menu />', () => {
<DropdownContext.Provider value={testContext}>{node}</DropdownContext.Provider>,
);
},
mount: (node: React.ReactNode) => {
const wrapper = mount(
<DropdownContext.Provider value={testContext}>{node}</DropdownContext.Provider>,
);
return wrapper.childAt(0);
},
refInstanceof: window.HTMLDivElement,
slots: {
root: {
Expand Down
9 changes: 1 addition & 8 deletions packages/mui-base/src/MenuButton/MenuButton.test.tsx
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 { act, createMount, createRenderer } from '@mui-internal/test-utils';
import { act, createRenderer } from '@mui-internal/test-utils';
import { MenuButton, menuButtonClasses } from '@mui/base/MenuButton';
import { DropdownContext, DropdownContextValue, DropdownActionTypes } from '@mui/base/useDropdown';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';
Expand All @@ -21,7 +21,6 @@ const testContext: DropdownContextValue = {
};

describe('<MenuButton />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<MenuButton />, () => ({
Expand All @@ -31,12 +30,6 @@ describe('<MenuButton />', () => {
<DropdownContext.Provider value={testContext}>{node}</DropdownContext.Provider>,
);
},
mount: (node: React.ReactNode) => {
const wrapper = mount(
<DropdownContext.Provider value={testContext}>{node}</DropdownContext.Provider>,
);
return wrapper.childAt(0);
},
refInstanceof: window.HTMLButtonElement,
slots: {
root: {
Expand Down
7 changes: 1 addition & 6 deletions packages/mui-base/src/MenuItem/MenuItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { MenuItem, menuItemClasses } from '@mui/base/MenuItem';
import { MenuProvider } from '@mui/base/useMenu';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';
Expand All @@ -23,18 +23,13 @@ const testContext = {
};

describe('<MenuItem />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<MenuItem />, () => ({
inheritComponent: 'li',
render: (node) => {
return render(<MenuProvider value={testContext}>{node}</MenuProvider>);
},
mount: (node: React.ReactNode) => {
const wrapper = mount(<MenuProvider value={testContext}>{node}</MenuProvider>);
return wrapper.childAt(0);
},
refInstanceof: window.HTMLLIElement,
testComponentPropWith: 'span',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';
import { expect } from 'chai';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { Modal, modalClasses as classes, ModalRootSlotProps } from '@mui/base/Modal';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Modal />', () => {
const mount = createMount();
const { render } = createRenderer();
let savedBodyStyle: CSSStyleDeclaration;

Expand All @@ -24,7 +23,6 @@ describe('<Modal />', () => {
() => ({
inheritComponent: 'div',
render,
mount,
refInstanceof: window.HTMLDivElement,
slots: {
root: {
Expand Down
19 changes: 1 addition & 18 deletions packages/mui-base/src/Option/Option.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { Option, optionClasses } from '@mui/base/Option';
import { SelectProvider } from '../useSelect/SelectProvider';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';
Expand All @@ -12,7 +12,6 @@ const dummyGetItemState = () => ({
});

describe('<Option />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<Option value={42} />, () => ({
Expand All @@ -32,22 +31,6 @@ describe('<Option />', () => {
</SelectProvider>,
);
},
mount: (node: React.ReactNode) => {
const wrapper = mount(
<SelectProvider
value={{
dispatch: () => {},
getItemIndex: () => 0,
getItemState: dummyGetItemState,
registerItem: () => ({ id: 0, deregister: () => {} }),
totalSubitemCount: 0,
}}
>
{node}
</SelectProvider>,
);
return wrapper.childAt(0);
},
refInstanceof: window.HTMLLIElement,
testComponentPropWith: 'span',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/OptionGroup/OptionGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import * as React from 'react';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { OptionGroup, optionGroupClasses } from '@mui/base/OptionGroup';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<OptionGroup />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<OptionGroup />, () => ({
inheritComponent: 'li',
render,
mount,
refInstanceof: window.HTMLLIElement,
testComponentPropWith: 'span',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Popper/Popper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, createMount, screen } from '@mui-internal/test-utils';
import { createRenderer, screen } from '@mui-internal/test-utils';
import { Popper, popperClasses } from '@mui/base/Popper';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Popper />', () => {
const { render } = createRenderer();
const mount = createMount();

const defaultProps = {
anchorEl: () => document.createElement('svg'),
Expand All @@ -17,7 +16,6 @@ describe('<Popper />', () => {
describeConformanceUnstyled(<Popper {...defaultProps} />, () => ({
inheritComponent: 'div',
render,
mount,
refInstanceof: window.HTMLDivElement,
skip: [
// https://github.com/facebook/react/issues/11565
Expand Down
3 changes: 0 additions & 3 deletions packages/mui-base/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import {
createMount,
createRenderer,
fireEvent,
act,
Expand All @@ -23,7 +22,6 @@ import { describeConformanceUnstyled } from '../../test/describeConformanceUnsty
// userEvent.setup() requires Safari 14 or up to work

describe('<Select />', () => {
const mount = createMount();
const { render: internalRender } = createRenderer();

async function render(
Expand All @@ -46,7 +44,6 @@ describe('<Select />', () => {
describeConformanceUnstyled(componentToTest, () => ({
inheritComponent: 'button',
render,
mount,
refInstanceof: window.HTMLButtonElement,
testComponentPropWith: 'span',
slots: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Slider/Slider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import * as React from 'react';
import { spy, stub } from 'sinon';
import { act, createRenderer, createMount, fireEvent, screen } from '@mui-internal/test-utils';
import { act, createRenderer, fireEvent, screen } from '@mui-internal/test-utils';
import {
Slider,
sliderClasses as classes,
Expand Down Expand Up @@ -31,14 +31,12 @@ describe('<Slider />', () => {
}
});

const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<Slider value={0} />, () => ({
classes,
inheritComponent: 'span',
render,
mount,
refInstanceof: window.HTMLSpanElement,
testComponentPropWith: 'div',
slots: {
Expand Down
5 changes: 1 addition & 4 deletions packages/mui-base/src/Snackbar/Snackbar.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 { act, createRenderer, createMount, fireEvent } from '@mui-internal/test-utils';
import { act, createRenderer, fireEvent } from '@mui-internal/test-utils';
import { Snackbar, snackbarClasses as classes } from '@mui/base/Snackbar';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

Expand All @@ -23,8 +23,6 @@ describe('<Snackbar />', () => {
return result;
}

const mount = createMount();

describeConformanceUnstyled(
<Snackbar open>
<div />
Expand All @@ -33,7 +31,6 @@ describe('<Snackbar />', () => {
classes,
inheritComponent: 'div',
render,
mount,
refInstanceof: window.HTMLDivElement,
slots: {
root: {
Expand Down
4 changes: 1 addition & 3 deletions packages/mui-base/src/Switch/Switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import * as React from 'react';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { expect } from 'chai';
import { Switch, SwitchOwnerState, switchClasses } from '@mui/base/Switch';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Switch />', () => {
const mount = createMount();
const { render } = createRenderer();

describeConformanceUnstyled(<Switch />, () => ({
inheritComponent: 'span',
render,
mount,
refInstanceof: window.HTMLSpanElement,
testComponentPropWith: 'span',
slots: {
Expand Down
19 changes: 1 addition & 18 deletions packages/mui-base/src/Tab/Tab.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as React from 'react';
import { createMount, createRenderer } from '@mui-internal/test-utils';
import { createRenderer } from '@mui-internal/test-utils';
import { Tab, tabClasses } from '@mui/base/Tab';
import { TabsListProvider, TabsListProviderValue } from '../useTabsList';
import { TabsContext } from '../Tabs';
import { describeConformanceUnstyled } from '../../test/describeConformanceUnstyled';

describe('<Tab />', () => {
const mount = createMount();
const { render } = createRenderer();

const testTabsListContext: TabsListProviderValue = {
Expand Down Expand Up @@ -38,22 +37,6 @@ describe('<Tab />', () => {

return { container, ...other };
},
mount: (node: any) => {
const wrapper = mount(
<TabsContext.Provider
value={{
value: 0,
onSelected() {},
registerTabIdLookup() {},
getTabId: () => '',
getTabPanelId: () => '',
}}
>
<TabsListProvider value={testTabsListContext}>{node}</TabsListProvider>
</TabsContext.Provider>,
);
return wrapper.childAt(0);
},
refInstanceof: window.HTMLButtonElement,
testComponentPropWith: 'div',
slots: {
Expand Down
Loading
Loading