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

Upgrade to include [email protected]; Fix tests that used deprecated features #83

Merged
merged 1 commit into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
language: node_js
matrix:
allow_failures:
Expand Down
13 changes: 4 additions & 9 deletions lib/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,17 @@ NavLink = React.createClass({
}
},
render: function() {
var context;
if (this.context && this.context.makePath) {
context = this.context;
} else if (this.props.context && this.props.context.makePath) {
context = this.props.context;
}

var context = this.props.context || this.context;
var routeName = this.props.routeName;
var newProps = {};
if (!this.props.href && routeName && context) {
this.props.href = context.makePath(routeName, this.props.navParams);
newProps.href = context.makePath(routeName, this.props.navParams);
}
return React.createElement(
'a',
objectAssign({}, {
onClick: this.dispatchNavAction
}, this.props),
}, this.props, newProps),
this.props.children
);
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"setimmediate": "^1.0.2"
},
"peerDependencies": {
"react": ">=0.12.0 <=0.13.0-rcx"
"react": ">=0.12.0 <=0.13.x"
},
"devDependencies": {
"chai": "^2.0.0",
Expand All @@ -37,8 +37,8 @@
"lodash": "^3.2.0",
"mocha": "^2.0.1",
"precommit-hook": "^1.0.2",
"react": ">=0.12.0 <=0.13.0-rcx",
"react-tools": ">=0.12.0 <=0.13.0-rcx"
"react": ">=0.12.0 <=0.13.x",
"react-tools": ">=0.12.0 <=0.13.x"
},
"jshintConfig": {
"node": true
Expand Down
24 changes: 24 additions & 0 deletions tests/mocks/MockAppComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var React = require('react/addons');
var RouterMixin = require('../../').RouterMixin;

var MockAppComponent = React.createClass({

mixins: [RouterMixin],

childContextTypes: {
executeAction: React.PropTypes.func,
getStore: React.PropTypes.func
},
getChildContext: function () {
return {
executeAction: this.props.context.executeAction,
getStore: this.props.context.getStore
};
},

render: function () {
return React.addons.cloneWithProps(this.props.children, {});
}
});

module.exports = MockAppComponent;
15 changes: 8 additions & 7 deletions tests/unit/lib/NavLink-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('NavLink', function () {
React = require('react/addons');
ReactTestUtils = React.addons.TestUtils;
NavLink = React.createFactory(require('../../../lib/NavLink'));
Wrapper = React.createFactory(require('../../mocks/MockAppComponent'));
testResult = {};
});

Expand All @@ -69,16 +70,16 @@ describe('NavLink', function () {
});
it ('only routeName defined', function () {
var navParams = {a: 1, b: 2};
var link = ReactTestUtils.renderIntoDocument(NavLink( {routeName:"foo", navParams:navParams, context:contextMock}, React.DOM.span(null, "bar")));
expect(link.props.href).to.equal('/foo/a/1/b/2');
var link = React.renderToString(NavLink( {routeName:"foo", navParams:navParams, context:contextMock}, React.DOM.span(null, "bar")));
expect(link).to.contain('href="/foo/a/1/b/2"');
});
it ('only routeName defined; use this.context.makePath', function (done) {
var navParams = {a: 1, b: 2};
React.withContext(contextMock, function () {
var link = React.renderToString(NavLink({routeName:"foo", navParams:navParams}));
expect(link).to.contain('href="/foo/a/1/b/2"');
done();
});
var link = React.renderToString(Wrapper({
context: contextMock
}, NavLink({routeName:"foo", navParams:navParams})));
expect(link).to.contain('href="/foo/a/1/b/2"');
done();
});
it ('none defined', function () {
var navParams = {a: 1, b: 2};
Expand Down