Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit e04c407

Browse files
committed
Fixed warnings and added snapshot test
1 parent a551b84 commit e04c407

File tree

7 files changed

+745
-13
lines changed

7 files changed

+745
-13
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { render } from "@testing-library/react";
2+
import React from "react";
3+
import Login from "./Login";
4+
import {RouterWrapper} from "../../dev/testUtils/RouterWrapper";
5+
6+
test("renders Login page", () => {
7+
const breadcrumb = render(
8+
<RouterWrapper>
9+
<Login />
10+
</RouterWrapper>
11+
);
12+
13+
expect(breadcrumb).toMatchSnapshot();
14+
});

src/components/basicElements/Login.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import logo from "../../assets/images/logos/logoWithWhiteBorder.png";
66

77
export interface LoginInputInterface {
88
handleSubmit: (event: FormEvent) => void,
9-
username: string|number|string[]|undefined,
9+
username: string | number | string[] | undefined,
1010
setUsername: Dispatch<SetStateAction<string>>,
11-
password: string|number|string[]|undefined,
11+
password: string | number | string[] | undefined,
1212
setPassword: Dispatch<SetStateAction<string>>,
1313
isLoading: boolean,
1414
setIsLoading: Dispatch<SetStateAction<boolean>>,
1515
stayLoggedIn: boolean,
1616
setStayLoggedIn: Dispatch<SetStateAction<boolean>>,
17-
errorMessage: string|null
17+
errorMessage: string | null
1818
}
1919

2020
function Login(): ReactElement {
@@ -125,7 +125,7 @@ export function LoginInput(props: LoginInputInterface) {
125125
<div>
126126
<Row className="mt-4 justify-content-center">
127127
<Col className="login-input">
128-
<Form onSubmit={handleSubmit} >
128+
<Form onSubmit={handleSubmit}>
129129
<Form.Group controlId="formBasicUsername">
130130
<Form.Control placeholder="Username" value={username}
131131
onChange={event => setUsername(event.target.value)}/>
Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,312 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renders Login page 1`] = `
4+
Object {
5+
"asFragment": [Function],
6+
"baseElement": <body>
7+
<div>
8+
9+
<div
10+
class="h-100 ml-0 mr-0 login-page container-fluid"
11+
>
12+
<div
13+
class="login-container pr-1 pl-1 mr-auto ml-auto"
14+
>
15+
<div
16+
class="login-intro"
17+
>
18+
<div
19+
class="justify-content-center row"
20+
>
21+
<img
22+
class="rounded"
23+
height="200px"
24+
src="logoWithWhiteBorder.png"
25+
width="auto"
26+
/>
27+
</div>
28+
<div
29+
class="justify-content-center row"
30+
>
31+
<h1>
32+
Greetings Traveller!
33+
</h1>
34+
</div>
35+
<div
36+
class="justify-content-center row"
37+
>
38+
<h2>
39+
Be welcome at FileFighter
40+
</h2>
41+
</div>
42+
</div>
43+
<div>
44+
<div
45+
class="mt-4 justify-content-center row"
46+
>
47+
<div
48+
class="login-input col"
49+
>
50+
<form
51+
class=""
52+
>
53+
<div
54+
class="form-group"
55+
>
56+
<input
57+
class="form-control"
58+
id="formBasicUsername"
59+
placeholder="Username"
60+
value=""
61+
/>
62+
</div>
63+
<div
64+
class="form-group"
65+
>
66+
<input
67+
class="form-control"
68+
id="formBasicPassword"
69+
placeholder="Password"
70+
type="password"
71+
value=""
72+
/>
73+
<small
74+
class="text-muted form-text"
75+
>
76+
Contact your administrator if you have forgotten your login details.
77+
</small>
78+
</div>
79+
<button
80+
class="btn btn-primary btn-block"
81+
type="submit"
82+
>
83+
<span
84+
aria-hidden="true"
85+
class="d-none spinner-grow spinner-grow-sm"
86+
role="status"
87+
/>
88+
89+
<span
90+
class="d-none"
91+
>
92+
isLoading...
93+
</span>
94+
Sign in
95+
</button>
96+
<div
97+
class="mt-3 justify-content-center form-group"
98+
>
99+
<div
100+
class="form-check"
101+
>
102+
<input
103+
checked=""
104+
class="form-check-input"
105+
id="formBasicCheckbox"
106+
type="checkbox"
107+
/>
108+
<label
109+
class="form-check-label"
110+
for="formBasicCheckbox"
111+
title=""
112+
>
113+
Keep me signed in*
114+
</label>
115+
</div>
116+
<small
117+
class="text-muted form-text"
118+
>
119+
*By clicking this, you accept the usage of cookies.
120+
</small>
121+
</div>
122+
<p
123+
class="text-danger"
124+
/>
125+
</form>
126+
</div>
127+
</div>
128+
</div>
129+
</div>
130+
</div>
131+
132+
</div>
133+
</body>,
134+
"container": <div>
135+
136+
<div
137+
class="h-100 ml-0 mr-0 login-page container-fluid"
138+
>
139+
<div
140+
class="login-container pr-1 pl-1 mr-auto ml-auto"
141+
>
142+
<div
143+
class="login-intro"
144+
>
145+
<div
146+
class="justify-content-center row"
147+
>
148+
<img
149+
class="rounded"
150+
height="200px"
151+
src="logoWithWhiteBorder.png"
152+
width="auto"
153+
/>
154+
</div>
155+
<div
156+
class="justify-content-center row"
157+
>
158+
<h1>
159+
Greetings Traveller!
160+
</h1>
161+
</div>
162+
<div
163+
class="justify-content-center row"
164+
>
165+
<h2>
166+
Be welcome at FileFighter
167+
</h2>
168+
</div>
169+
</div>
170+
<div>
171+
<div
172+
class="mt-4 justify-content-center row"
173+
>
174+
<div
175+
class="login-input col"
176+
>
177+
<form
178+
class=""
179+
>
180+
<div
181+
class="form-group"
182+
>
183+
<input
184+
class="form-control"
185+
id="formBasicUsername"
186+
placeholder="Username"
187+
value=""
188+
/>
189+
</div>
190+
<div
191+
class="form-group"
192+
>
193+
<input
194+
class="form-control"
195+
id="formBasicPassword"
196+
placeholder="Password"
197+
type="password"
198+
value=""
199+
/>
200+
<small
201+
class="text-muted form-text"
202+
>
203+
Contact your administrator if you have forgotten your login details.
204+
</small>
205+
</div>
206+
<button
207+
class="btn btn-primary btn-block"
208+
type="submit"
209+
>
210+
<span
211+
aria-hidden="true"
212+
class="d-none spinner-grow spinner-grow-sm"
213+
role="status"
214+
/>
215+
216+
<span
217+
class="d-none"
218+
>
219+
isLoading...
220+
</span>
221+
Sign in
222+
</button>
223+
<div
224+
class="mt-3 justify-content-center form-group"
225+
>
226+
<div
227+
class="form-check"
228+
>
229+
<input
230+
checked=""
231+
class="form-check-input"
232+
id="formBasicCheckbox"
233+
type="checkbox"
234+
/>
235+
<label
236+
class="form-check-label"
237+
for="formBasicCheckbox"
238+
title=""
239+
>
240+
Keep me signed in*
241+
</label>
242+
</div>
243+
<small
244+
class="text-muted form-text"
245+
>
246+
*By clicking this, you accept the usage of cookies.
247+
</small>
248+
</div>
249+
<p
250+
class="text-danger"
251+
/>
252+
</form>
253+
</div>
254+
</div>
255+
</div>
256+
</div>
257+
</div>
258+
259+
</div>,
260+
"debug": [Function],
261+
"findAllByAltText": [Function],
262+
"findAllByDisplayValue": [Function],
263+
"findAllByLabelText": [Function],
264+
"findAllByPlaceholderText": [Function],
265+
"findAllByRole": [Function],
266+
"findAllByTestId": [Function],
267+
"findAllByText": [Function],
268+
"findAllByTitle": [Function],
269+
"findByAltText": [Function],
270+
"findByDisplayValue": [Function],
271+
"findByLabelText": [Function],
272+
"findByPlaceholderText": [Function],
273+
"findByRole": [Function],
274+
"findByTestId": [Function],
275+
"findByText": [Function],
276+
"findByTitle": [Function],
277+
"getAllByAltText": [Function],
278+
"getAllByDisplayValue": [Function],
279+
"getAllByLabelText": [Function],
280+
"getAllByPlaceholderText": [Function],
281+
"getAllByRole": [Function],
282+
"getAllByTestId": [Function],
283+
"getAllByText": [Function],
284+
"getAllByTitle": [Function],
285+
"getByAltText": [Function],
286+
"getByDisplayValue": [Function],
287+
"getByLabelText": [Function],
288+
"getByPlaceholderText": [Function],
289+
"getByRole": [Function],
290+
"getByTestId": [Function],
291+
"getByText": [Function],
292+
"getByTitle": [Function],
293+
"queryAllByAltText": [Function],
294+
"queryAllByDisplayValue": [Function],
295+
"queryAllByLabelText": [Function],
296+
"queryAllByPlaceholderText": [Function],
297+
"queryAllByRole": [Function],
298+
"queryAllByTestId": [Function],
299+
"queryAllByText": [Function],
300+
"queryAllByTitle": [Function],
301+
"queryByAltText": [Function],
302+
"queryByDisplayValue": [Function],
303+
"queryByLabelText": [Function],
304+
"queryByPlaceholderText": [Function],
305+
"queryByRole": [Function],
306+
"queryByTestId": [Function],
307+
"queryByText": [Function],
308+
"queryByTitle": [Function],
309+
"rerender": [Function],
310+
"unmount": [Function],
311+
}
312+
`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { render } from "@testing-library/react";
2+
import React from "react";
3+
import Registration from "./Registration";
4+
import {RouterWrapper} from "../../../dev/testUtils/RouterWrapper";
5+
6+
test("renders Login page", () => {
7+
const breadcrumb = render(
8+
<RouterWrapper>
9+
<Registration />
10+
</RouterWrapper>
11+
);
12+
13+
expect(breadcrumb).toMatchSnapshot();
14+
});

src/components/pages/User/Registration.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {ReactElement, useEffect, useState} from "react";
2-
import {Alert, Col, Container, Row} from "react-bootstrap";
2+
import {Alert, Container, Row} from "react-bootstrap";
33
import {notMinStrLength} from "../../../background/methods/checkInput";
44
import fileFighter from "../../../assets/images/logos/adventurer-run.gif";
55
import {registerNewUser} from "../../../background/api/registration";
@@ -34,7 +34,7 @@ export default function Registration(): ReactElement {
3434
repositionSubmitLogo()
3535
}, [registrationContainer, logoSubmit])
3636

37-
const handleSubmit = async (newUser:UserInformationInputInterface) => {
37+
const handleSubmit = async (newUser: UserInformationInputInterface) => {
3838
console.log("[REGISTRATION] handleSubmit")
3939
if (!newUser.username) {
4040
handleAlertVisibility(DEFAULT_ALERT_DURATION, "danger", "Error: Please choose an username.")

0 commit comments

Comments
 (0)