Guest User

Untitled

a guest
Mar 14th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. describe('signup form', () => {
  2. test('should contain a form element', () => {
  3. const wrapper = shallow(<SignupForm {...defaultProps} />);
  4. expect(wrapper.type()).toBe('form');
  5. });
  6.  
  7. test('should contain an InputField componant with the props relative to username field', () => {
  8. const wrapper = shallow(<SignupForm {...defaultProps} username="foo" />);
  9. const usernameInputField = wrapper.findWhere(
  10. n => n.type() === InputField && n.prop('name') === 'username',
  11. );
  12. expect(usernameInputField.length).toEqual(1);
  13. expect(usernameInputField.props()).toEqual({
  14. error: 'usernameError',
  15. name: 'username',
  16. type: 'text',
  17. value: 'foo',
  18. placeholder: "Nom d'utilisateur",
  19. onChange: defaultProps.onUsernameChange,
  20. });
  21. });
  22. test('should contain an InputField componant with the props relative to email field', () => {
  23. const wrapper = shallow(<SignupForm {...defaultProps} email="foo@example.com" />);
  24. const emailInputField = wrapper.findWhere(n => n.type() === InputField && n.prop('name') === 'email');
  25. expect(emailInputField.length).toEqual(1);
  26. expect(emailInputField.props()).toEqual({
  27. error: 'emailError',
  28. name: 'email',
  29. type: 'text',
  30. value: 'foo@example.com',
  31. placeholder: 'Adresse email',
  32. onChange: defaultProps.onEmailChange,
  33. });
  34. });
  35. test('should contain an InputField componant with the props relative to password field', () => {
  36. const wrapper = shallow(<SignupForm {...defaultProps} password="password" />);
  37. const passwordInputField = wrapper.findWhere(
  38. n => n.type() === InputField && n.prop('name') === 'password',
  39. );
  40. expect(passwordInputField.length).toEqual(1);
  41. expect(passwordInputField.props()).toEqual({
  42. error: 'passwordError',
  43. name: 'password',
  44. type: 'password',
  45. value: 'password',
  46. placeholder: 'Mot de passe',
  47. onChange: defaultProps.onPasswordChange,
  48. });
  49. });
  50. test('should contain an InputField componant with the props relative to passwordConfirmation field', () => {
  51. const wrapper = shallow(<SignupForm {...defaultProps} passwordConfirmation="passwordConfirmation" />);
  52. const passwordConfirmationField = wrapper.findWhere(
  53. n => n.type() === InputField && n.prop('name') === 'passwordConfirmation',
  54. );
  55. expect(passwordConfirmationField.length).toEqual(1);
  56. expect(passwordConfirmationField.props()).toEqual({
  57. error: 'passwordConfirmationError',
  58. name: 'passwordConfirmation',
  59. type: 'password',
  60. value: 'passwordConfirmation',
  61. placeholder: 'Confirmation du mot de passe',
  62. onChange: defaultProps.onPasswordConfirmationChange,
  63. });
  64. });
  65. test('should contain a submit input with the submit prop as onClick value', () => {
  66. const submit = jest.fn();
  67. const wrapper = shallow(<SignupForm {...defaultProps} submit={submit} />);
  68. const submitInput = wrapper.find('input[type="submit"]');
  69. expect(submitInput.length).toEqual(1);
  70. expect(submitInput.prop('onClick')).toBe(submit);
  71. });
  72. });
Add Comment
Please, Sign In to add comment