Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 242 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. describe('signup form', () => {
  2.   test('should contain a form element', () => {
  3.     const wrapper = shallow(
  4.       <SignupForm username="" email="" password="" passwordConfirmation="" submit={jest.fn()} />,
  5.     );
  6.     expect(wrapper.type()).toBe('form');
  7.   });
  8.   test('should contain a username text input with the username prop as value and proper placeholder', () => {
  9.     const wrapper = shallow(
  10.       <SignupForm username="foo" email="" password="" passwordConfirmation="" submit={jest.fn()} />,
  11.     );
  12.     const usernameInput = wrapper.find('input[name="username"]');
  13.     expect(usernameInput.length).toEqual(1);
  14.     expect(usernameInput.prop('type')).toEqual('text');
  15.     expect(usernameInput.prop('value')).toEqual('foo');
  16.     expect(usernameInput.prop('placeholder')).toEqual("Nom d'utilisateur");
  17.   });
  18.   test('should contain a email input with the email prop as value and proper placeholder', () => {
  19.     const wrapper = shallow(
  20.       <SignupForm
  21.         email="foo@example.com"
  22.         username=""
  23.         password=""
  24.         passwordConfirmation=""
  25.         submit={jest.fn()}
  26.       />,
  27.     );
  28.     const emailInput = wrapper.find('input[name="email"]');
  29.     expect(emailInput.length).toEqual(1);
  30.     expect(emailInput.prop('type')).toEqual('text');
  31.     expect(emailInput.prop('value')).toEqual('foo@example.com');
  32.     expect(emailInput.prop('placeholder')).toEqual('Adresse email');
  33.   });
  34.   test('should contain a password input field wit the password prop as value and proper placeholder', () => {
  35.     const wrapper = shallow(
  36.       <SignupForm password="password" username="" email="" passwordConfirmation="" submit={jest.fn()} />,
  37.     );
  38.     const passwordInput = wrapper.find('input[name="password"]');
  39.     expect(passwordInput.length).toEqual(1);
  40.     expect(passwordInput.prop('type')).toEqual('password');
  41.     expect(passwordInput.prop('value')).toEqual('password');
  42.     expect(passwordInput.prop('placeholder')).toEqual('Mot de passe');
  43.   });
  44.   test('should contain a password confirmation input field with the passwordConfirmation prop as value and proper placeholder', () => {
  45.     const wrapper = shallow(
  46.       <SignupForm
  47.         passwordConfirmation="passwordConfirmation"
  48.         username=""
  49.         email=""
  50.         password=""
  51.         submit={jest.fn()}
  52.       />,
  53.     );
  54.     const passwordConfirmationInput = wrapper.find('input[name="passwordConfirmation"]');
  55.     expect(passwordConfirmationInput.length).toEqual(1);
  56.     expect(passwordConfirmationInput.prop('type')).toEqual('password');
  57.     expect(passwordConfirmationInput.prop('value')).toEqual('passwordConfirmation');
  58.     expect(passwordConfirmationInput.prop('placeholder')).toEqual('Confirmation du mot de passe');
  59.   });
  60.   test('should contain a submit input with the submit prop as onClick value', () => {
  61.     const submit = jest.fn();
  62.     const wrapper = shallow(
  63.       <SignupForm passwordConfirmation="" username="" email="" password="" submit={submit} />,
  64.     );
  65.     const submitInput = wrapper.find('input[type="submit"]');
  66.     expect(submitInput.length).toEqual(1);
  67.     expect(submitInput.prop('onClick')).toBe(submit);
  68.   });
  69. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top