This file contains 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("when input changed", () => { | |
it("should change property name in the state", () => { | |
const componentWrapper = shallow(<Login />); | |
componentWrapper.find('#email').simulate('change', {target: {name: 'email', value: 'blah@gmail.com'}}); | |
expect(componentWrapper.state('email')).toEqual('blah@gmail.com'); | |
}) | |
}); |
This file contains 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('when valid email was filled', () => { | |
beforeEach(() => { | |
subscribe = jest.fn(); | |
wrapper = mount(<Subscription subscribe={subscribe}/>); | |
}); | |
describe('and when form was submitted', () => { | |
beforeEach(() => { | |
... | |
wrapper.find('#email').simulate('change', {target: {name: 'email', value: 'blah@gmail.com'}}); |
This file contains 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
export class Subscription extends Component { | |
state = { | |
email: '' | |
}; | |
render() { | |
return ( | |
<input | |
id="email" | |
type="email" |
This file contains 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
export class Subscription extends Component { | |
state = { | |
email: '' | |
}; | |
render() { | |
return ( | |
... | |
<MarketingContent logo={logo}/> | |
<EmailInput onChange={(email) => this.onEmailChange(email)}/> |
This file contains 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
it('should render marketing content with correct logo', () => { | |
expect(wrapper.find('MarketingContent').length).toBe(1); | |
expect(wrapper.find('MarketingContent').props("logo")).toEqual(logo); | |
}); | |
it('should render email input and pass it onChange method', () => { | |
expect(wrapper.find('EmailInput').length).toBe(1); | |
expect(wrapper.find('EmailInput').props("onChange")).toEqual(this.onChange); | |
}); |
This file contains 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 App extends Component { | |
state = { | |
users: [] | |
}; | |
async fetchUsers() { | |
const users = await fetch('http://totallyhardcodedurl.com/stupid'); | |
this.setState({users}); | |
} |
This file contains 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 App extends Component { | |
state = { | |
users: [{name: 'Jim', surname: 'Smith', age: 33}] | |
}; | |
componentDidMount() { | |
this.fetchUsers(); | |
} |
This file contains 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 App extends Component { | |
render() { | |
return ( | |
<div className="App"> | |
<Header/> | |
<UserList/> | |
</div> | |
); | |
} |
This file contains 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 UserList extends Component { | |
static propTypes = { | |
fetchUsers: PropTypes.func.isRequired, | |
saveUsers: PropTypes.func.isRequired | |
}; | |
state = { | |
users: [{name: 'Jim', surname: 'Smith', age: 33}] | |
}; |
This file contains 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 App extends Component { | |
... | |
async fetchUsers() { | |
const users = await fetch('http://totallyhardcodedurl.com/stupid'); | |
this.setState({users}); | |
} | |
... |
OlderNewer