From 0248488e8a9a40db9a06733ebd9eedd3bbadb080 Mon Sep 17 00:00:00 2001
From: Jakob Fleisch <jakob.fleisch@gmail.com>
Date: Fri, 19 Mar 2021 20:46:35 +0100
Subject: [PATCH] Add client test for login and registration forms

---
 app/client/src/App.test.js | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/app/client/src/App.test.js b/app/client/src/App.test.js
index 45a71e3..9170134 100644
--- a/app/client/src/App.test.js
+++ b/app/client/src/App.test.js
@@ -1,5 +1,5 @@
 import React from 'react';
-import { render } from '@testing-library/react';
+import { render, waitForElement, fireEvent } from '@testing-library/react';
 import App from './App';
 
 test.skip('renders header title "ToDo App"', () => {
@@ -13,3 +13,21 @@ test('renders a header title', () => {
   const header = container.querySelector('.header-main')
   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))
+});
-- 
GitLab