I'm working with a React-Router test stubbing example, and I've never seen this class convention before. I'm guessing this is ES6 specific?
var stubRouterContext = (Component, props, stubs) => {
function RouterStub() { }
Object.assign(RouterStub, {
makePath () {},
makeHref () {},
transitionTo () {},
replaceWith () {},
goBack () {},
getCurrentPath () {},
getCurrentRoutes () {},
getCurrentPathname () {},
getCurrentParams () {},
getCurrentQuery () {},
isActive () {},
getRouteAtDepth() {},
setRouteComponentAtDepth() {}
}, stubs);
return React.createClass({
childContextTypes: {
router: React.PropTypes.func,
routeDepth: React.PropTypes.number
},
getChildContext () {
return {
router: RouterStub,
routeDepth: 0
};
},
render () {
return <Component {...props} />
}
});
};
And why do I get TypeError: object is not function when I do this?
var Subject = stubRouterContext(Handler, props);
Here's the link to the doc https://github.com/rackt/react-router/blob/master/docs/guides/testing.md