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
class ComponentToBeTested extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isActive: false | |
}; | |
this.handleButtonClick = this.handleButtonClick.bind(this); | |
} | |
handleButtonClick() { |
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
{ | |
} |
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
Foo.propTypes = { | |
customProp: function(props, propName, componentName) { | |
if (!/matchme/.test(props[propName])) { | |
return new Error( | |
'Invalid prop `' + propName + '` supplied to' + | |
' `' + componentName + '`. Validation failed.' | |
); | |
} | |
} | |
}; |
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
Chart.propTypes = { | |
config: PropTypes.shape({ | |
series: PropTypes.array.isRequired, | |
xAxis: PropTypes.shape({ | |
categories: PropTypes.array, | |
}), | |
}).isRequired, | |
chartType: PropTypes.arrayOf(PropTypes.string).isRequired, | |
currentChartType: PropTypes.oneOf(['view', 'conversion']), | |
}; |
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
Chart.propTypes = { | |
config: PropTypes.object.isRequired, | |
chartType: PropTypes.array.isRequired, | |
currentChartType: PropTypes.string, | |
}; |
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
describe('<Foo />', () => { | |
describe('#componentDidMount', () => { | |
it('should return foo', () => { | |
const cb = sinon.spy(); | |
mount(<Foo callback={cb} />); | |
expect(cb.calledOnce).to.be.eq(true); | |
}); | |
}); | |
}); |
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
class Foo extends React.Component { | |
componentDidMount() { | |
this.props.callback(); | |
} | |
/* ... */ | |
render() { /* ... */ } | |
} |
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
/* ... */ | |
class Foo extends React.Component { | |
state = { test: 'test' } | |
/* ... */ | |
test() { | |
return this.state.test; | |
} |
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
/* ... */ | |
class Foo extends React.Component { | |
/* ... */ | |
test() { | |
return 'foo'; | |
} | |
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
/* ... */ | |
class Foo extends React.Component { | |
/* ... */ | |
test() { | |
return 'foo'; | |
} | |