From 3e5972bccee6f3680418e0d7c24fdd336db5ea68 Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Sun, 21 Mar 2021 20:45:31 +0100 Subject: [PATCH] Test login form existence --- src/App.tsx | 4 ++-- src/components/LoginForm/LoginForm.test.tsx | 10 +++------- src/components/LoginForm/LoginForm.tsx | 9 +++++++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 84f3739..45b47ad 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,10 +1,10 @@ import React from 'react'; -import { Form } from './components/LoginForm/LoginForm'; +import { LoginForm } from './components/LoginForm/LoginForm'; export const App: React.FC = () => ( <div className="App" data-testid="App"> <header className="App-header"> - <Form /> + <LoginForm /> </header> </div> ); diff --git a/src/components/LoginForm/LoginForm.test.tsx b/src/components/LoginForm/LoginForm.test.tsx index ff13e8f..3b1eaa4 100644 --- a/src/components/LoginForm/LoginForm.test.tsx +++ b/src/components/LoginForm/LoginForm.test.tsx @@ -2,13 +2,9 @@ import React from 'react'; import { render, fireEvent } from '@testing-library/react'; import { LoginForm } from './LoginForm'; -describe('Email input', () => { - it('Should handle email insertion and validation'); - - it('renders button', () => { +describe('<LoginForm />', () => { + it('renders form', () => { const wrapper = render(<LoginForm />); - - console.log(wrapper.queryByTestId('LoginButton')); - expect(wrapper.queryByTestId('LoginButton')).toBeTruthy(); + expect(wrapper.queryByTestId('LoginForm')).toBeTruthy(); }); }); diff --git a/src/components/LoginForm/LoginForm.tsx b/src/components/LoginForm/LoginForm.tsx index fea60f6..d77ced7 100644 --- a/src/components/LoginForm/LoginForm.tsx +++ b/src/components/LoginForm/LoginForm.tsx @@ -21,7 +21,7 @@ const useStyles = makeStyles((theme: Theme) => }), ); -export const Form: React.FC = () => { +export const LoginForm: React.FC = () => { interface formData { email: string; password: string; @@ -49,7 +49,11 @@ export const Form: React.FC = () => { const classes = useStyles(); return ( - <form className={classes.form} onSubmit={handleSubmit}> + <form + className={classes.form} + onSubmit={handleSubmit} + data-testid="LoginForm" + > <TextField variant="outlined" margin="normal" @@ -83,6 +87,7 @@ export const Form: React.FC = () => { fullWidth variant="contained" color="primary" + data-testid="LoginButton" className={classes.submit} > Sign In -- GitLab