@@ -104,10 +104,44 @@ describeWithDOM('mount', () => {
104
104
</div>` ) ;
105
105
} ) ;
106
106
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
+ itIf ( is ( '> 0.13' ) , '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
+ console . log ( firstArg ) ;
126
+ expect ( firstArg ) . to . be . instanceOf ( HTMLElement ) ;
127
+ } ) ;
128
+
129
+ itIf ( is ( '> 0.13' ) , 'passes an HTML element to `ref` when sub-rendered' , ( ) => {
130
+ const spy = sinon . spy ( ) ;
131
+ class Foo extends React . Component {
132
+ render ( ) {
133
+ return < div ref = { spy } /> ;
134
+ }
135
+ }
136
+ mount ( < Foo /> ) ;
137
+ expect ( spy ) . to . have . property ( 'callCount' , 1 ) ;
138
+
139
+ // sanity check
140
+ expect ( document . createElement ( 'div' ) ) . to . be . instanceOf ( HTMLElement ) ;
141
+
142
+ const [ [ firstArg ] ] = spy . args ;
143
+ expect ( firstArg ) . to . be . instanceOf ( HTMLElement ) ;
144
+ } ) ;
111
145
} ) ;
112
146
113
147
describe ( 'wrapping invalid elements' , ( ) => {
0 commit comments