Javascript 组件没有';我测试时不渲染
我有一个很奇怪的问题。我使用Javascript 组件没有';我测试时不渲染,javascript,coffeescript,reactjs,jasmine,react-router,Javascript,Coffeescript,Reactjs,Jasmine,React Router,我有一个很奇怪的问题。我使用jasmine 2.0,react 0.13.3,react路由器0.13.3和其他软件包。我有一个测试套件,它无法找到DerenderedomComponentWithTag()。请考虑确切的例子: React = require('react') TestUtils = require('react/addons.js').addons.TestUtils ReactRouterContext = require('../../helpers/react_rout
jasmine 2.0
,react 0.13.3
,react路由器0.13.3
和其他软件包。我有一个测试套件,它无法找到DerenderedomComponentWithTag()
。请考虑确切的例子:
React = require('react')
TestUtils = require('react/addons.js').addons.TestUtils
ReactRouterContext = require('../../helpers/react_router_context_helper.coffee')
NewSession = require('../../../../app/coffee/components/sessions/new.coffee')
subject = ReactRouterContext(NewSession)
describe 'NewSession', ->
it 'should send the query after clicking on the button', ->
instance = TestUtils.renderIntoDocument(<subject />)
h3 = TestUtils.findRenderedDOMComponentWithTag(instance, 'h3') # can't find at least one h3 tag
it 'should render wrong login/password on error', ->
pending()
it 'should process user after successful login', ->
# localStorage
# alt.js
# redirect
pending()
这似乎很愚蠢,但我只需要将
主题
替换为主题
。现在,把我的变量看作是组件类,而不是div标签。
Subject = ReactRouterContext(NewSession)
instance = TestUtils.renderIntoDocument(<Subject />)
Subject=ReactRouterContext(新闻会话)
instance=TestUtils.renderIntoDocument()
# react_router_context_helper.coffee
React = require('react')
objectAssign = require('object-assign')
module.exports = (Component, props, stubs) ->
RouterStub = ->
objectAssign RouterStub, {
makePath: ->
makeHref: ->
transitionTo: ->
replaceWith: ->
goBack: ->
getCurrentPath: ->
getCurrentRoutes: ->
getCurrentPathname: ->
getCurrentParams: ->
getCurrentQuery: ->
isActive: ->
getRouteAtDepth: ->
setRouteComponentAtDepth: ->
}, stubs
React.createClass
childContextTypes:
router: React.PropTypes.func
routeDepth: React.PropTypes.number
getChildContext: ->
{
router: RouterStub
routeDepth: 0
}
render: ->
React.createElement Component, props
Subject = ReactRouterContext(NewSession)
instance = TestUtils.renderIntoDocument(<Subject />)