Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('signup form', () => {
- test('should contain a form element', () => {
- const wrapper = shallow(<SignupForm {...defaultProps} />);
- expect(wrapper.type()).toBe('form');
- });
- test('should contain an InputField componant with the props relative to username field', () => {
- const wrapper = shallow(<SignupForm {...defaultProps} username="foo" />);
- const usernameInputField = wrapper.findWhere(
- n => n.type() === InputField && n.prop('name') === 'username',
- );
- expect(usernameInputField.length).toEqual(1);
- expect(usernameInputField.props()).toEqual({
- error: 'usernameError',
- name: 'username',
- type: 'text',
- value: 'foo',
- placeholder: "Nom d'utilisateur",
- onChange: defaultProps.onUsernameChange,
- });
- });
- test('should contain an InputField componant with the props relative to email field', () => {
- const wrapper = shallow(<SignupForm {...defaultProps} email="foo@example.com" />);
- const emailInputField = wrapper.findWhere(n => n.type() === InputField && n.prop('name') === 'email');
- expect(emailInputField.length).toEqual(1);
- expect(emailInputField.props()).toEqual({
- error: 'emailError',
- name: 'email',
- type: 'text',
- value: 'foo@example.com',
- placeholder: 'Adresse email',
- onChange: defaultProps.onEmailChange,
- });
- });
- test('should contain an InputField componant with the props relative to password field', () => {
- const wrapper = shallow(<SignupForm {...defaultProps} password="password" />);
- const passwordInputField = wrapper.findWhere(
- n => n.type() === InputField && n.prop('name') === 'password',
- );
- expect(passwordInputField.length).toEqual(1);
- expect(passwordInputField.props()).toEqual({
- error: 'passwordError',
- name: 'password',
- type: 'password',
- value: 'password',
- placeholder: 'Mot de passe',
- onChange: defaultProps.onPasswordChange,
- });
- });
- test('should contain an InputField componant with the props relative to passwordConfirmation field', () => {
- const wrapper = shallow(<SignupForm {...defaultProps} passwordConfirmation="passwordConfirmation" />);
- const passwordConfirmationField = wrapper.findWhere(
- n => n.type() === InputField && n.prop('name') === 'passwordConfirmation',
- );
- expect(passwordConfirmationField.length).toEqual(1);
- expect(passwordConfirmationField.props()).toEqual({
- error: 'passwordConfirmationError',
- name: 'passwordConfirmation',
- type: 'password',
- value: 'passwordConfirmation',
- placeholder: 'Confirmation du mot de passe',
- onChange: defaultProps.onPasswordConfirmationChange,
- });
- });
- test('should contain a submit input with the submit prop as onClick value', () => {
- const submit = jest.fn();
- const wrapper = shallow(<SignupForm {...defaultProps} submit={submit} />);
- const submitInput = wrapper.find('input[type="submit"]');
- expect(submitInput.length).toEqual(1);
- expect(submitInput.prop('onClick')).toBe(submit);
- });
- });
Add Comment
Please, Sign In to add comment