Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LoginPage extends Component {
- constructor(props) {
- super(props);
- this.state = {
- username: '',
- password: ''
- };
- this.handleChange = this.handleChange.bind(this);
- ...
- }
- handleChange(event) {
- this.setState({[event.target.name]: event.target.value})
- }
- ...
- return(
- ...
- <TextField name='username' onChange={this.handleChange} />
- )
- it('handles change', () => {
- const spy = sinon.spy(LoginPage.prototype, 'handleChange');
- const _wrapper = shallow(<LoginPage />);
- spy({
- event: {
- target: {
- name: 'username',
- value: 'password'
- }
- }
- }
- );
- expect(_wrapper.state().username).to.equal('username');
- expect(_wrapper.state().password).to.equal('password')
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement