Skip to content
Snippets Groups Projects
Verified Commit a72b02b6 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Test setup

parent c7a5ddd2
No related branches found
No related tags found
2 merge requests!11Basic implementation of login page,!8Test setup
Pipeline #11454 failed
import React from 'react'; import React from 'react';
import { render, screen } from '@testing-library/react'; import { render, screen } from '@testing-library/react';
import App from './App'; import { App } from './App';
test('renders learn react link', () => { describe('<App />', () => {
render(<App />); it('renders without crashing', () => {
const linkElement = screen.getByText(/learn react/i); const wrapper = render(<App />);
expect(linkElement).toBeInTheDocument(); expect(wrapper.queryByTestId('App')).toBeTruthy();
});
}); });
import React from 'react'; import React from 'react';
import { Form } from './components/LoginForm/index'; import { Form } from './components/LoginForm/LoginForm';
export const App: React.FC = () => ( export const App: React.FC = () => (
<div className="App"> <div className="App">
......
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();
});
});
...@@ -4,13 +4,6 @@ import TextField from '@material-ui/core/TextField'; ...@@ -4,13 +4,6 @@ import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import { isEmailValid } from './emailValidator'; import { isEmailValid } from './emailValidator';
/**
* TODO
* Add enviroment variable for host
* Connect to api
* Add cookie session fetch
*/
const useStyles = makeStyles((theme: Theme) => const useStyles = makeStyles((theme: Theme) =>
createStyles({ createStyles({
root: { root: {
...@@ -42,15 +35,6 @@ export const Form: React.FC = () => { ...@@ -42,15 +35,6 @@ export const Form: React.FC = () => {
}; };
const [formValues, setFormValues] = useState<formData>(defaultValues); 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 => { const handleSubmit = (event: React.FormEvent): void => {
event.preventDefault(); event.preventDefault();
const errors: Array<string> = []; const errors: Array<string> = [];
...@@ -59,10 +43,6 @@ export const Form: React.FC = () => { ...@@ -59,10 +43,6 @@ export const Form: React.FC = () => {
console.log('Email address not valid'); console.log('Email address not valid');
} else { } else {
console.log(formValues); console.log(formValues);
fetch(
'https://jsonplaceholder.typicode.com/posts',
requestOptions,
).then((response) => response.json());
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment