-
-
Save thegoleffect/36b07ffb386443db511a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react/addons'), | |
TestUtils = React.addons.TestUtils, | |
TestContext = require('./TestContext'), | |
App = require('./App.jsx'), | |
app = TestContext.getRouterComponent(App); | |
describe('App', function() { | |
it('has something', function() { | |
expect(app.getDOMNode().textContent).toContain('something'); | |
}); | |
it('has nav', function() { | |
var nav = TestUtils.findRenderedDOMComponentWithTag(app, 'nav'); | |
expect(nav).toBeDefined(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Router = require('react-router'), | |
Route = Router.Route, | |
React = require('react/addons'), | |
TestUtils = React.addons.TestUtils, | |
TestLocation = require('react-router/modules/locations/TestLocation'); | |
var TestContext = { | |
getRouterComponent: function(targetComponent) { | |
var component, | |
div = document.createElement('div'), | |
routes = [ | |
React.createFactory(Route)({ | |
name: 'test', | |
handler: targetComponent | |
}) | |
]; | |
TestLocation.history = ['/test']; | |
Router.run(routes, TestLocation, function (Handler) { | |
var mainComponent = React.render(React.createFactory(Handler)({}), div); | |
component = TestUtils.findRenderedComponentWithType(mainComponent, | |
targetComponent); | |
}); | |
return component; | |
} | |
}; | |
module.exports = TestContext; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment