diff --git a/packages/material-ui/src/Backdrop/Backdrop.test.js b/packages/material-ui/src/Backdrop/Backdrop.test.js
index a003a341df6b7b..6abd4f5d2cc293 100644
--- a/packages/material-ui/src/Backdrop/Backdrop.test.js
+++ b/packages/material-ui/src/Backdrop/Backdrop.test.js
@@ -1,6 +1,11 @@
import React from 'react';
import { assert } from 'chai';
-import { createMount, createShallow, getClasses, testRef } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ createShallow,
+ describeConformance,
+ getClasses,
+} from '@material-ui/core/test-utils';
import Backdrop from './Backdrop';
describe('', () => {
@@ -18,13 +23,15 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render a backdrop div', () => {
const wrapper = shallow();
assert.strictEqual(wrapper.childAt(0).hasClass('woofBackdrop'), true);
assert.strictEqual(wrapper.childAt(0).hasClass(classes.root), true);
});
-
- it('does forward refs', () => {
- testRef(, mount);
- });
});
diff --git a/packages/material-ui/src/Box/Box.test.js b/packages/material-ui/src/Box/Box.test.js
index c675885fccc827..66bc21415cf059 100644
--- a/packages/material-ui/src/Box/Box.test.js
+++ b/packages/material-ui/src/Box/Box.test.js
@@ -1,6 +1,6 @@
import React from 'react';
import { assert } from 'chai';
-import { createMount } from '@material-ui/core/test-utils';
+import { createMount, describeConformance } from '@material-ui/core/test-utils';
import Box from './Box';
describe('', () => {
@@ -14,6 +14,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
const testChildren =
Hello World
;
it('renders children and box content', () => {
diff --git a/packages/material-ui/src/FilledInput/FilledInput.test.js b/packages/material-ui/src/FilledInput/FilledInput.test.js
index 867accc42e48b7..3a6e50e62ba474 100644
--- a/packages/material-ui/src/FilledInput/FilledInput.test.js
+++ b/packages/material-ui/src/FilledInput/FilledInput.test.js
@@ -1,6 +1,11 @@
import React from 'react';
import { assert } from 'chai';
-import { createMount, findOutermostIntrinsic, getClasses } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ describeConformance,
+ findOutermostIntrinsic,
+ getClasses,
+} from '@material-ui/core/test-utils';
import FilledInput from './FilledInput';
describe('', () => {
@@ -16,6 +21,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render a ', () => {
const wrapper = mount();
const root = findOutermostIntrinsic(wrapper);
diff --git a/packages/material-ui/src/Grid/Grid.test.js b/packages/material-ui/src/Grid/Grid.test.js
index 36ecb20fb70e4a..902e11f6682712 100644
--- a/packages/material-ui/src/Grid/Grid.test.js
+++ b/packages/material-ui/src/Grid/Grid.test.js
@@ -1,17 +1,30 @@
import React from 'react';
import { assert } from 'chai';
-import { createShallow, getClasses } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ createShallow,
+ describeConformance,
+ getClasses,
+} from '@material-ui/core/test-utils';
import Grid from './Grid';
describe('', () => {
+ let mount;
let shallow;
let classes;
before(() => {
+ mount = createMount();
shallow = createShallow({ dive: true });
classes = getClasses();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render', () => {
const wrapper = shallow();
assert.strictEqual(wrapper.name(), 'div');
diff --git a/packages/material-ui/src/Input/Input.test.js b/packages/material-ui/src/Input/Input.test.js
index a4fdddbc35f33a..5a2be386aeaca3 100644
--- a/packages/material-ui/src/Input/Input.test.js
+++ b/packages/material-ui/src/Input/Input.test.js
@@ -1,6 +1,10 @@
import React from 'react';
import { assert } from 'chai';
-import { createMount, findOutermostIntrinsic } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ describeConformance,
+ findOutermostIntrinsic,
+} from '@material-ui/core/test-utils';
import Input from './Input';
describe('', () => {
@@ -14,6 +18,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render a ', () => {
const wrapper = mount();
assert.strictEqual(findOutermostIntrinsic(wrapper).type(), 'div');
diff --git a/packages/material-ui/src/Menu/Menu.test.js b/packages/material-ui/src/Menu/Menu.test.js
index e5dfeea7a735c4..65ad22fedefee7 100644
--- a/packages/material-ui/src/Menu/Menu.test.js
+++ b/packages/material-ui/src/Menu/Menu.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { spy } from 'sinon';
import { assert } from 'chai';
-import { createMount, getClasses, testRef } from '@material-ui/core/test-utils';
+import { createMount, describeConformance, getClasses } from '@material-ui/core/test-utils';
import Popover from '../Popover';
import Menu from './Menu';
import MenuList from '../MenuList';
@@ -11,13 +11,12 @@ const MENU_LIST_HEIGHT = 100;
describe('', () => {
let classes;
let mount;
- let defaultProps;
+ const defaultProps = {
+ open: false,
+ anchorEl: () => document.createElement('div'),
+ };
before(() => {
- defaultProps = {
- open: false,
- anchorEl: document.createElement('div'),
- };
classes = getClasses();
mount = createMount();
});
@@ -26,9 +25,11 @@ describe('', () => {
mount.cleanUp();
});
- it('does forward refs', () => {
- testRef(, mount);
- });
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
it('should render a Popover', () => {
const wrapper = mount();
diff --git a/packages/material-ui/src/MenuList/MenuList.test.js b/packages/material-ui/src/MenuList/MenuList.test.js
index 529f4858fd966c..c355dc50e5e5f1 100644
--- a/packages/material-ui/src/MenuList/MenuList.test.js
+++ b/packages/material-ui/src/MenuList/MenuList.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { assert } from 'chai';
import { stub } from 'sinon';
-import { createMount, testRef } from '@material-ui/core/test-utils';
+import { createMount, describeConformance } from '@material-ui/core/test-utils';
import MenuList from './MenuList';
import getScrollbarSize from '../utils/getScrollbarSize';
@@ -26,9 +26,11 @@ describe('', () => {
mount.cleanUp();
});
- it('does forward refs', () => {
- testRef(, mount);
- });
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLUListElement,
+ }));
describe('list node', () => {
let wrapper;
diff --git a/packages/material-ui/src/NativeSelect/NativeSelectInput.test.js b/packages/material-ui/src/NativeSelect/NativeSelectInput.test.js
index b10253c8f0da26..725c8ca1dcaec0 100644
--- a/packages/material-ui/src/NativeSelect/NativeSelectInput.test.js
+++ b/packages/material-ui/src/NativeSelect/NativeSelectInput.test.js
@@ -1,8 +1,7 @@
import React from 'react';
import { assert } from 'chai';
import { spy } from 'sinon';
-import { createShallow, createMount } from '@material-ui/core/test-utils';
-import MenuItem from '../MenuItem';
+import { createShallow, createMount, describeConformance } from '@material-ui/core/test-utils';
import NativeSelectInput from './NativeSelectInput';
describe('', () => {
@@ -13,15 +12,15 @@ describe('', () => {
value: 10,
IconComponent: 'div',
children: [
- ,
- ,
- ,
+ ,
],
};
@@ -34,6 +33,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance( {}} />, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLSelectElement,
+ }));
+
it('should render a native select', () => {
const wrapper = shallow(
diff --git a/packages/material-ui/src/OutlinedInput/OutlinedInput.test.js b/packages/material-ui/src/OutlinedInput/OutlinedInput.test.js
index a00f2ff3bf93c3..9ec17e1b7cdfae 100644
--- a/packages/material-ui/src/OutlinedInput/OutlinedInput.test.js
+++ b/packages/material-ui/src/OutlinedInput/OutlinedInput.test.js
@@ -1,6 +1,10 @@
import React from 'react';
import { assert } from 'chai';
-import { createMount, findOutermostIntrinsic } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ describeConformance,
+ findOutermostIntrinsic,
+} from '@material-ui/core/test-utils';
import OutlinedInput from './OutlinedInput';
import NotchedOutline from './NotchedOutline';
@@ -15,6 +19,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render a ', () => {
const wrapper = mount();
assert.strictEqual(findOutermostIntrinsic(wrapper).type(), 'div');
diff --git a/packages/material-ui/src/Popover/Popover.test.js b/packages/material-ui/src/Popover/Popover.test.js
index 62194e28ef4d0d..70054c15404145 100644
--- a/packages/material-ui/src/Popover/Popover.test.js
+++ b/packages/material-ui/src/Popover/Popover.test.js
@@ -5,6 +5,7 @@ import PropTypes from 'prop-types';
import {
createShallow,
createMount,
+ describeConformance,
findOutermostIntrinsic,
getClasses,
} from '@material-ui/core/test-utils';
@@ -18,7 +19,10 @@ describe('', () => {
let shallow;
let mount;
let classes;
- let defaultProps;
+ const defaultProps = {
+ open: false,
+ anchorEl: () => document.createElement('div'),
+ };
before(() => {
shallow = createShallow({ dive: true });
@@ -28,16 +32,18 @@ describe('', () => {
,
);
- defaultProps = {
- open: false,
- anchorEl: document.createElement('div'),
- };
});
after(() => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
describe('root node', () => {
it('should render a Modal with an invisible backdrop as the root node', () => {
const wrapper = mount(
diff --git a/packages/material-ui/src/RadioGroup/RadioGroup.test.js b/packages/material-ui/src/RadioGroup/RadioGroup.test.js
index 0e9818bc5fb0b3..7be00c2e405cc9 100644
--- a/packages/material-ui/src/RadioGroup/RadioGroup.test.js
+++ b/packages/material-ui/src/RadioGroup/RadioGroup.test.js
@@ -1,7 +1,11 @@
import React from 'react';
import { assert } from 'chai';
import { spy } from 'sinon';
-import { createMount, findOutermostIntrinsic, testRef } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ describeConformance,
+ findOutermostIntrinsic,
+} from '@material-ui/core/test-utils';
import FormGroup from '../FormGroup';
import Radio from '../Radio';
import RadioGroup from './RadioGroup';
@@ -22,9 +26,11 @@ describe('', () => {
return wrapper.find(`input[value="${value}"]`).first();
}
- it('does forward refs', () => {
- testRef(, mount);
- });
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
it('should render a FormGroup with the radiogroup role', () => {
const wrapper = mount();
diff --git a/packages/material-ui/src/Select/Select.test.js b/packages/material-ui/src/Select/Select.test.js
index dbea6e46cd0584..cd6fd8390ddf40 100644
--- a/packages/material-ui/src/Select/Select.test.js
+++ b/packages/material-ui/src/Select/Select.test.js
@@ -1,6 +1,6 @@
import React from 'react';
import { assert } from 'chai';
-import { getClasses, createMount } from '@material-ui/core/test-utils';
+import { getClasses, createMount, describeConformance } from '@material-ui/core/test-utils';
import MenuItem from '../MenuItem';
import Input from '../Input';
import Select from './Select';
@@ -31,6 +31,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLDivElement,
+ }));
+
it('should render a correct top element', () => {
const wrapper = mount();
assert.strictEqual(wrapper.find(Input).exists(), true);
diff --git a/packages/material-ui/src/StepIcon/StepIcon.test.js b/packages/material-ui/src/StepIcon/StepIcon.test.js
index 2ac08c10aca52b..de0cd632f0fd42 100644
--- a/packages/material-ui/src/StepIcon/StepIcon.test.js
+++ b/packages/material-ui/src/StepIcon/StepIcon.test.js
@@ -2,7 +2,7 @@ import React from 'react';
import { assert } from 'chai';
import CheckCircle from '../internal/svg-icons/CheckCircle';
import Warning from '../internal/svg-icons/Warning';
-import { createShallow, createMount } from '@material-ui/core/test-utils';
+import { createShallow, createMount, describeConformance } from '@material-ui/core/test-utils';
import StepIcon from './StepIcon';
import SvgIcon from '../SvgIcon';
@@ -19,6 +19,12 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.SVGSVGElement,
+ }));
+
it('renders when completed', () => {
const wrapper = mount();
const checkCircle = wrapper.find(CheckCircle);
diff --git a/packages/material-ui/src/Switch/Switch.test.js b/packages/material-ui/src/Switch/Switch.test.js
index 433bae7279bba7..80f28b9c40699e 100644
--- a/packages/material-ui/src/Switch/Switch.test.js
+++ b/packages/material-ui/src/Switch/Switch.test.js
@@ -1,19 +1,36 @@
import React from 'react';
import { assert } from 'chai';
import clsx from 'clsx';
-import { createShallow, getClasses } from '@material-ui/core/test-utils';
+import {
+ createMount,
+ createShallow,
+ describeConformance,
+ getClasses,
+} from '@material-ui/core/test-utils';
import SwitchBase from '../internal/SwitchBase';
import Switch from './Switch';
describe('', () => {
+ let mount;
let shallow;
let classes;
before(() => {
+ mount = createMount();
shallow = createShallow({ untilSelector: 'span' });
classes = getClasses();
});
+ after(() => {
+ mount.cleanUp();
+ });
+
+ describeConformance(, () => ({
+ mount,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLSpanElement,
+ }));
+
describe('styleSheet', () => {
it('should have the classes required for SwitchBase', () => {
assert.strictEqual(typeof classes.root, 'string');
diff --git a/packages/material-ui/src/TablePagination/TablePagination.test.js b/packages/material-ui/src/TablePagination/TablePagination.test.js
index aa847b370c962b..3116c5ec04fcec 100644
--- a/packages/material-ui/src/TablePagination/TablePagination.test.js
+++ b/packages/material-ui/src/TablePagination/TablePagination.test.js
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import {
createShallow,
createMount,
+ describeConformance,
findOutermostIntrinsic,
getClasses,
} from '@material-ui/core/test-utils';
@@ -22,6 +23,17 @@ describe('', () => {
let shallow;
let mount;
+ function mountInTable(node) {
+ const wrapper = mount(
+ ,
+ );
+ return wrapper.find('tr').childAt(0);
+ }
+
before(() => {
classes = getClasses(
{}} page={0} rowsPerPage={1} />,
@@ -34,6 +46,15 @@ describe('', () => {
mount.cleanUp();
});
+ describeConformance(
+ {}} page={0} rowsPerPage={1} />,
+ () => ({
+ mount: mountInTable,
+ only: ['refForwarding'],
+ refInstanceof: window.HTMLTableCellElement,
+ }),
+ );
+
it('should render a TableCell', () => {
const wrapper = mount(
diff --git a/packages/material-ui/src/test-utils/describeConformance.js b/packages/material-ui/src/test-utils/describeConformance.js
index 8ca3526b1b5af0..0366cf28134189 100644
--- a/packages/material-ui/src/test-utils/describeConformance.js
+++ b/packages/material-ui/src/test-utils/describeConformance.js
@@ -119,7 +119,9 @@ const fullSuite = {
* @property {string} classes - `classes` of the component provided by `@material-ui/styles`
* @property {string} inheritComponent - The element type that receives spread props.
* @property {function} mount - Should be a return value from createMount
+ * @property {string[]?} only - If specified only run the tests listed
* @property {boolean} refInstanceof - `ref` will be an instanceof this constructor.
+ * @property {string[]?} skip - Skip the specified tests
* @property {string?} testComponentPropWith - The host component that should be rendered instead.
*/
@@ -132,10 +134,13 @@ const fullSuite = {
*
*/
export default function describeConformance(minimalElement, getOptions) {
+ const { only = Object.keys(fullSuite), skip = [] } = getOptions();
describe('Material-UI component API', () => {
- Object.keys(fullSuite).forEach(testKey => {
- const test = fullSuite[testKey];
- test(minimalElement, getOptions);
- });
+ Object.keys(fullSuite)
+ .filter(testKey => only.indexOf(testKey) !== -1 && skip.indexOf(testKey) === -1)
+ .forEach(testKey => {
+ const test = fullSuite[testKey];
+ test(minimalElement, getOptions);
+ });
});
}