@@ -3,6 +3,7 @@ import React, {
33 createClass ,
44 createElement ,
55 cloneElement ,
6+ findDOMNode ,
67 Component ,
78 PropTypes ,
89 unstable_renderSubtreeIntoContainer ,
@@ -284,6 +285,41 @@ describe('preact-compat', () => {
284285 } ) ;
285286 } ) ;
286287
288+ describe ( 'findDOMNode()' , ( ) => {
289+ class Helper extends React . Component {
290+ render ( { something} ) {
291+ if ( something == null ) return null ;
292+ if ( something === false ) return null ;
293+ return < div > </ div > ;
294+ }
295+ }
296+
297+ it ( 'should return DOM Node if render is not false nor null' , ( ) => {
298+ let scratch = document . createElement ( 'div' ) ;
299+ ( document . body || document . documentElement ) . appendChild ( scratch ) ;
300+ const helper = React . render ( < Helper /> , scratch ) ;
301+ expect ( findDOMNode ( helper ) ) . to . be . instanceof ( Node ) ;
302+ } ) ;
303+
304+ // NOTE: React.render() returning false or null has the component pointing
305+ // to no DOM Node, in contrast, Preact always render an empty Text DOM Node.
306+ xit ( 'should return null if render returns false' , ( ) => {
307+ let scratch = document . createElement ( 'div' ) ;
308+ ( document . body || document . documentElement ) . appendChild ( scratch ) ;
309+ const helper = React . render ( < Helper something = { false } /> , scratch ) ;
310+ expect ( findDOMNode ( helper ) ) . to . be . null ;
311+ } ) ;
312+
313+ // NOTE: React.render() returning false or null has the component pointing
314+ // to no DOM Node, in contrast, Preact always render an empty Text DOM Node.
315+ xit ( 'should return null if render returns null' , ( ) => {
316+ let scratch = document . createElement ( 'div' ) ;
317+ ( document . body || document . documentElement ) . appendChild ( scratch ) ;
318+ const helper = React . render ( < Helper something = { null } /> , scratch ) ;
319+ expect ( findDOMNode ( helper ) ) . to . be . null ;
320+ } ) ;
321+ } ) ;
322+
287323 describe ( 'unstable_renderSubtreeIntoContainer' , ( ) => {
288324 class Inner extends Component {
289325 render ( ) {
0 commit comments