Ajout test submit formulaire

This commit is contained in:
wpetit 2020-03-09 14:31:15 +01:00
parent 4e554d5ef2
commit 3c5d146762

View File

@ -7,6 +7,25 @@ import React from 'react';
import { ExtendedUserForm as UserForm } from './UserForm'; import { ExtendedUserForm as UserForm } from './UserForm';
describe('<UserForm />', () => { describe('<UserForm />', () => {
describe('submit', () => {
test('correctly submitted', () => {
const onSubmit = jest.fn();
const form = mount(<UserForm onSubmit={onSubmit} />);
form.find('[name="username"]').simulate('change', { target: { value: 'test' } });
form.find('[name="password"]').simulate('change', { target: { value: 'test' } });
form.find('[name="passwordVerification"]').simulate('change', { target: { value: 'test' } });
form.find('form').simulate('submit');
expect(onSubmit).toHaveBeenCalledWith({
username: 'test',
password: 'test',
passwordVerification: 'test'
});
})
});
describe('username validation', () => { describe('username validation', () => {
test('empty username', () => { test('empty username', () => {