Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Update tests to use new React APIs; Use createElement instead of Reac…
Browse files Browse the repository at this point in the history
…t.DOM
  • Loading branch information
Michael Ridgway committed Nov 4, 2014
1 parent 72ed052 commit 57c1c26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/NavLink.js
Expand Up @@ -34,7 +34,8 @@ NavLink = React.createClass({
if (!this.props.href && routeName && context && context.makePath) {
this.props.href = context.makePath(routeName, this.props.navParams);
}
return React.DOM.a(
return React.createElement(
'a',
{onClick:this.dispatchNavAction, href:this.props.href},
this.props.children
);
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/lib/NavLink-test.js
Expand Up @@ -42,7 +42,7 @@ describe('NavLink', function () {
global.navigator = global.window.navigator;
React = require('react/addons');
ReactTestUtils = React.addons.TestUtils;
NavLink = require('../../../lib/NavLink');
NavLink = React.createFactory(require('../../../lib/NavLink'));
testResult = {};
});

Expand All @@ -54,12 +54,12 @@ describe('NavLink', function () {

describe('render()', function () {
it ('href defined', function () {
var link = ReactTestUtils.renderIntoDocument(NavLink( {href:"/foo"}, React.DOM.span(null, "bar")));
var link = ReactTestUtils.renderIntoDocument(NavLink( {href:"/foo", context:contextMock}, React.DOM.span(null, "bar")));
expect(link.props.href).to.equal('/foo');
expect(link.getDOMNode().textContent).to.equal('bar');
});
it ('both href and routeName defined', function () {
var link = ReactTestUtils.renderIntoDocument(NavLink( {routeName:"fooo", href:"/foo"}, React.DOM.span(null, "bar")));
var link = ReactTestUtils.renderIntoDocument(NavLink( {routeName:"fooo", href:"/foo", context:contextMock}, React.DOM.span(null, "bar")));
expect(link.props.href).to.equal('/foo');
});
it ('only routeName defined', function () {
Expand Down

0 comments on commit 57c1c26

Please sign in to comment.