@@ -77,36 +77,25 @@ function testPropsSpread(element, options) {
7777}
7878
7979/**
80- * Some Material-UI components can forward their refs via `innerRef`
80+ * Tests that the `ref` of a component will return the correct instance
8181 *
82- * TODO: Use `ref` once WithStylesTest is no longer required
82+ * This is determined by a given constructor i.e. a React.Component or HTMLElement for
83+ * components that forward their ref and attach it to a host component.
8384 *
8485 * @param {React.ReactElement } element
8586 * @param {Object } options
86- * @param {boolean } options.forwardRef - If `true` then this component forwards `ref`
87+ * @param {FunctionConstructor } options.refInstanceof - `ref` will be an instanceof this constructor.
8788 */
88- function testRefForwarding ( element , options ) {
89- const { forwardRef , mount } = options ;
89+ function testRef ( element , options ) {
90+ const { refInstanceof , mount } = options ;
9091
91- describe ( 'prop: innerRef' , ( ) => {
92- before ( ( ) => {
93- // just to swallow possible error messages from attaching refs to function components
94- consoleErrorMock . spy ( ) ;
95- } ) ;
96-
97- after ( ( ) => {
98- consoleErrorMock . reset ( ) ;
99- } ) ;
100-
101- it ( `does ${ ! forwardRef ? 'not' : '' } forward ref` , ( ) => {
92+ describe ( 'ref' , ( ) => {
93+ it ( `attaches the ref to an instance of ${ refInstanceof } ` , ( ) => {
10294 const ref = React . createRef ( ) ;
95+ // TODO use `ref` once `WithStylesTest` is removed
10396 mount ( React . cloneElement ( element , { innerRef : ref } ) ) ;
10497
105- if ( ! forwardRef ) {
106- assert . strictEqual ( ref . current , null ) ;
107- } else {
108- assert . ok ( ref . current ) ;
109- }
98+ assert . instanceOf ( ref . current , refInstanceof ) ;
11099 } ) ;
111100 } ) ;
112101}
@@ -115,7 +104,7 @@ const fullSuite = {
115104 class : testClassName ,
116105 componentProp : testComponentProp ,
117106 propsSpread : testPropsSpread ,
118- refForwarding : testRefForwarding ,
107+ refForwarding : testRef ,
119108} ;
120109
121110/**
@@ -127,7 +116,7 @@ const fullSuite = {
127116 * @param {string } options.classes - see testClassName
128117 * @param {string } options.inheritComponentName - see testPropsSpread
129118 * @param {function } options.mount - Should be a return value from createMount
130- * @param {boolean } options.forwardRef - see test testRefForwarding
119+ * @param {boolean } options.refInstanceof - see test testRef
131120 * @param {string? } options.testComponentPropWith - see test testComponentProp
132121 */
133122export default function describeConformance ( minimalElement , options ) {
0 commit comments