Skip to content

Instantly share code, notes, and snippets.

@ianshea
Created August 14, 2015 04:40
Show Gist options
  • Save ianshea/8ba588b7d69049468a8c to your computer and use it in GitHub Desktop.
Save ianshea/8ba588b7d69049468a8c to your computer and use it in GitHub Desktop.
React Router Test Stub
class Stub extends React.Component {
static childContextTypes = {
router: React.PropTypes.object.isRequired
};
getChildContext() {
return {
router: {
makePath(pathname, query) { },
makeHref(pathname, query) { },
transitionTo(pathname, query, state=null) { },
replaceWith(pathname, query, state=null) { },
go(n) { },
goBack() { },
goForward() { },
isActive(pathname, query) { }
}
};
}
render() {
return this.props.children();
}
}
@ianshea
Copy link
Author

ianshea commented Aug 14, 2015

Pulled this out of a React Router issue. Will try and go back and find the issue and give credit where it's due!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment