diff --git a/test/utils/describeConformanceV5.js b/test/utils/describeConformanceV5.js index 0f5fadbffa204b..89f163bc991b1a 100644 --- a/test/utils/describeConformanceV5.js +++ b/test/utils/describeConformanceV5.js @@ -12,6 +12,13 @@ import { testRootClass, } from './describeConformance'; +function throwMissingPropError(field) { + throw new Error(`missing "${field}" in options + + > describeConformanceV5(element, () => options) +`); +} + /** * Material-UI components have a `components` prop that allows rendering a different * Components from @inheritComponent @@ -41,6 +48,15 @@ function testThemeDefaultProps(element, getOptions) { it("respect theme's defaultProps", () => { const testProp = 'data-id'; const { muiName, render } = getOptions(); + + if (!muiName) { + throwMissingPropError('muiName'); + } + + if (!render) { + throwMissingPropError('render'); + } + const theme = createMuiTheme({ components: { [muiName]: { @@ -76,6 +92,14 @@ function testThemeStyleOverrides(element, getOptions) { return; } + if (!muiName) { + throwMissingPropError('muiName'); + } + + if (!render) { + throwMissingPropError('render'); + } + const testStyle = { marginTop: '13px', }; @@ -199,6 +223,14 @@ function testThemeVariants(element, getOptions) { throw new Error('missing testVariantProps'); } + if (!muiName) { + throwMissingPropError('muiName'); + } + + if (!render) { + throwMissingPropError('render'); + } + const testStyle = { marginTop: '13px', }; @@ -251,14 +283,16 @@ const fullSuite = { export default function describeConformanceV5(minimalElement, getOptions) { const { after: runAfterHook = () => {}, only = Object.keys(fullSuite), skip = [] } = getOptions(); + const filteredTests = Object.keys(fullSuite).filter( + (testKey) => only.indexOf(testKey) !== -1 && skip.indexOf(testKey) === -1, + ); + describe('Material-UI component API', () => { after(runAfterHook); - Object.keys(fullSuite) - .filter((testKey) => only.indexOf(testKey) !== -1 && skip.indexOf(testKey) === -1) - .forEach((testKey) => { - const test = fullSuite[testKey]; - test(minimalElement, getOptions); - }); + filteredTests.forEach((testKey) => { + const test = fullSuite[testKey]; + test(minimalElement, getOptions); + }); }); }