From 3c5d146762bea489719ba7f32b3addfa54de79ee Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 9 Mar 2020 14:31:15 +0100 Subject: [PATCH] Ajout test submit formulaire --- frontend/src/components/UserForm.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/src/components/UserForm.test.js b/frontend/src/components/UserForm.test.js index 4c9ee6c..87639ec 100644 --- a/frontend/src/components/UserForm.test.js +++ b/frontend/src/components/UserForm.test.js @@ -7,6 +7,25 @@ import React from 'react'; import { ExtendedUserForm as UserForm } from './UserForm'; describe('', () => { + + describe('submit', () => { + test('correctly submitted', () => { + const onSubmit = jest.fn(); + const form = mount(); + + 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', () => { test('empty username', () => {