Skip to content
Snippets Groups Projects
Commit 0248488e authored by Jakob Fleisch's avatar Jakob Fleisch
Browse files

Add client test for login and registration forms

parent a3c3cb0e
No related branches found
No related tags found
No related merge requests found
import React from 'react'; import React from 'react';
import { render } from '@testing-library/react'; import { render, waitForElement, fireEvent } from '@testing-library/react';
import App from './App'; import App from './App';
test.skip('renders header title "ToDo App"', () => { test.skip('renders header title "ToDo App"', () => {
...@@ -13,3 +13,21 @@ test('renders a header title', () => { ...@@ -13,3 +13,21 @@ test('renders a header title', () => {
const header = container.querySelector('.header-main') const header = container.querySelector('.header-main')
expect(header).toHaveTextContent(/.+/); expect(header).toHaveTextContent(/.+/);
}); });
test('renders a login form', async () => {
const { getByText } = render(<App />);
await waitForElement(() => getByText(/Sign in/i))
await waitForElement(() => getByText(/Email/i))
await waitForElement(() => getByText(/Password/i))
await waitForElement(() => getByText(/Login/i))
});
test('renders registration form when register button clicked', async () => {
const { getByText } = render(<App />);
await waitForElement(() => getByText(/Signup/i))
fireEvent.click(getByText('Signup'))
await waitForElement(() => getByText(/Your name/i))
await waitForElement(() => getByText(/Your email/i))
await waitForElement(() => getByText(/Your password/i))
await waitForElement(() => getByText(/Create User/i))
});
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