diff --git a/src/App.test.tsx b/src/App.test.tsx index 2a68616d9846ed7d3bfb9f28ca1eb4d51b2c2f84..39ef6e5e60aa05ecb8faae0011be11704ce7125f 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -1,9 +1,10 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import App from './App'; +import { App } from './App'; -test('renders learn react link', () => { - render(<App />); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); +describe('<App />', () => { + it('renders without crashing', () => { + const wrapper = render(<App />); + expect(wrapper.queryByTestId('App')).toBeTruthy(); + }); }); diff --git a/src/App.tsx b/src/App.tsx index 6e5c72dfb7d5e20371e0e4eeede0792db17e5179..97d6154976862e2968b035871e4c09b8491fbeec 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Form } from './components/LoginForm/index'; +import { Form } from './components/LoginForm/LoginForm'; export const App: React.FC = () => ( <div className="App"> diff --git a/src/components/LoginForm/LoginForm.test.tsx b/src/components/LoginForm/LoginForm.test.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ff13e8f04ad1de49f158c146c7c8d0552f79a239 --- /dev/null +++ b/src/components/LoginForm/LoginForm.test.tsx @@ -0,0 +1,14 @@ +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', () => { + const wrapper = render(<LoginForm />); + + console.log(wrapper.queryByTestId('LoginButton')); + expect(wrapper.queryByTestId('LoginButton')).toBeTruthy(); + }); +}); diff --git a/src/components/LoginForm/index.tsx b/src/components/LoginForm/LoginForm.tsx similarity index 83% rename from src/components/LoginForm/index.tsx rename to src/components/LoginForm/LoginForm.tsx index 2eb912db81ae61dd67ac82e731dce918a217db45..fea60f62beb129a8868668d8ba60ed70b88b60ab 100644 --- a/src/components/LoginForm/index.tsx +++ b/src/components/LoginForm/LoginForm.tsx @@ -4,13 +4,6 @@ import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; import { isEmailValid } from './emailValidator'; -/** - * TODO - * Add enviroment variable for host - * Connect to api - * Add cookie session fetch - */ - const useStyles = makeStyles((theme: Theme) => createStyles({ root: { @@ -42,15 +35,6 @@ export const Form: React.FC = () => { }; const [formValues, setFormValues] = useState<formData>(defaultValues); - const requestOptions = { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - email: formValues.email, - password: formValues.password, - }), - }; - const handleSubmit = (event: React.FormEvent): void => { event.preventDefault(); const errors: Array<string> = []; @@ -59,10 +43,6 @@ export const Form: React.FC = () => { console.log('Email address not valid'); } else { console.log(formValues); - fetch( - 'https://jsonplaceholder.typicode.com/posts', - requestOptions, - ).then((response) => response.json()); } };