i'm writing tests react application. when try render nested component, got error titlebar not defined
, test fails.
jest.dontmock('fuw.js'); jest.dontmock('titlebar.js'); var react = require('react/addons'); var titlebar = require('../js/components/titlebar.js'); var firstusewindow = require('../js/components/windows/firstusewindow.js'); var testutils = react.addons.testutils; describe('first use wizard', function(){ aftereach(function(done){//cleanup dom react.unmountcomponentatnode(document.body); settimeout(done); }); var firstusewindowelement = testutils.renderintodocument( <div> <firstusewindow /> </div> ); });
the firstusewindow contains titlebar element causes error.
fuw.js
if (react === undefined) { var react = require('react/addons'); } var firstusewindow = react.createclass({ firstusecomplete:function(){ }, render:function(){ return( <div> <titlebar text="tested" /> </div> ); } }); if (module !== undefined) { module.exports = firstusewindow; }
titlebar.js
if (react === undefined) { var react = require('react/addons'); } var titlebar = react.createclass({ render:function(){ return( <header classname="bar bar-nav"> <h1 classname="title">{this.props.text}</h1> </header> ); } }); if (module != undefined) { module.exports = titlebar; }
title bar undefined because not being required in fuw.js
Comments
Post a Comment