@@ -104,10 +104,43 @@ describeWithDOM('mount', () => {
104104</div>` ) ;
105105 } ) ;
106106
107- it ( 'calls ref' , ( ) => {
108- const spy = sinon . spy ( ) ;
109- mount ( < div ref = { spy } /> ) ;
110- expect ( spy ) . to . have . property ( 'callCount' , 1 ) ;
107+ describeWithDOM ( 'refs' , ( ) => {
108+ it ( 'calls ref' , ( ) => {
109+ const spy = sinon . spy ( ) ;
110+ mount ( < div ref = { spy } /> ) ;
111+ expect ( spy ) . to . have . property ( 'callCount' , 1 ) ;
112+ } ) ;
113+
114+ /* global HTMLElement */
115+
116+ it ( 'passes an HTML element to `ref` when root rendered' , ( ) => {
117+ const spy = sinon . spy ( ) ;
118+ mount ( < div ref = { spy } /> ) ;
119+ expect ( spy ) . to . have . property ( 'callCount' , 1 ) ;
120+
121+ // sanity check
122+ expect ( document . createElement ( 'div' ) ) . to . be . instanceOf ( HTMLElement ) ;
123+
124+ const [ [ firstArg ] ] = spy . args ;
125+ expect ( firstArg ) . to . be . instanceOf ( HTMLElement ) ;
126+ } ) ;
127+
128+ it ( 'passes an HTML element to `ref` when sub-rendered' , ( ) => {
129+ const spy = sinon . spy ( ) ;
130+ class Foo extends React . Component {
131+ render ( ) {
132+ return < div ref = { spy } /> ;
133+ }
134+ }
135+ mount ( < Foo /> ) ;
136+ expect ( spy ) . to . have . property ( 'callCount' , 1 ) ;
137+
138+ // sanity check
139+ expect ( document . createElement ( 'div' ) ) . to . be . instanceOf ( HTMLElement ) ;
140+
141+ const [ [ firstArg ] ] = spy . args ;
142+ expect ( firstArg ) . to . be . instanceOf ( HTMLElement ) ;
143+ } ) ;
111144 } ) ;
112145
113146 describe ( 'wrapping invalid elements' , ( ) => {
0 commit comments