Skip to content

Commit 3d29cb7

Browse files
committed
Add test for DeleteAeroplane and Update snapshots
1 parent fa37797 commit 3d29cb7

File tree

6 files changed

+173
-3
lines changed

6 files changed

+173
-3
lines changed

src/__tests__/DeleteAeroplane.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { BrowserRouter } from 'react-router-dom';
4+
import { Provider } from 'react-redux';
5+
import store from '../redux/store';
6+
7+
import DeleteAeroplane from '../components/DeleteAeroplane';
8+
9+
test('renders DeleteAeroplane component correctly', () => {
10+
const { container } = render(
11+
<Provider store={store}>
12+
<BrowserRouter>
13+
<DeleteAeroplane />
14+
</BrowserRouter>
15+
</Provider>,
16+
);
17+
expect(container).toMatchSnapshot();
18+
});

src/__tests__/ReservationCard.test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { BrowserRouter } from 'react-router-dom';
4+
import { Provider } from 'react-redux';
5+
import store from '../redux/store';
6+
7+
import ReservationCard from '../components/ReservationCard';
8+
9+
test('renders ReservationCard component correctly', () => {
10+
const aeroplane = {
11+
name: 'Dragon 1',
12+
reserved_date: '2023-9-9',
13+
start_time: '10:00',
14+
end_time: '11:00',
15+
start_location: 'Lagos',
16+
destination: 'Abuja',
17+
id: 1,
18+
};
19+
20+
const { container } = render(
21+
<Provider store={store}>
22+
<BrowserRouter>
23+
<ReservationCard aeroplane={aeroplane} />
24+
</BrowserRouter>
25+
</Provider>,
26+
);
27+
expect(container).toMatchSnapshot();
28+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renders DeleteAeroplane component correctly 1`] = `
4+
<div>
5+
<div
6+
class="col-sm-6 col-lg-8"
7+
>
8+
<h3
9+
class="text-center"
10+
>
11+
Delete Aeroplane
12+
</h3>
13+
<small
14+
class="text-center d-block mb-5"
15+
>
16+
Click on delete button to delete aeroplane
17+
</small>
18+
<div>
19+
No aeroplanes yet
20+
</div>
21+
</div>
22+
</div>
23+
`;

src/__tests__/__snapshots__/Navigation.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ exports[`renders Navigation component correctly 1`] = `
5151
class="d-none d-md-block"
5252
>
5353
<div
54-
class="position-absolute top-0 start-0 vh-100 bg-light border-end d-flex flex-column w-0"
54+
class="position-fixed top-0 start-0 vh-100 bg-light border-end d-flex flex-column w-0"
5555
id="sidebar-wrapper"
5656
>
5757
<div

src/__tests__/__snapshots__/Register.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ exports[`renders Register component correctly 1`] = `
88
<p
99
class="container offScreen"
1010
/>
11-
<h1>
11+
<h3>
1212
Register
13-
</h1>
13+
</h3>
1414
<form>
1515
<label
1616
for="username"
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renders ReservationCard component correctly 1`] = `
4+
<div>
5+
<div
6+
class="col-lg-6 mb-4"
7+
>
8+
<div
9+
class="sc-bdnyFh dFAyrg card"
10+
>
11+
<h2
12+
class="sc-dlniIP iLvzBS card-title"
13+
>
14+
Reservation Details
15+
</h2>
16+
<div
17+
class="sc-gtsqUy jFmrNm"
18+
>
19+
<p
20+
class="sc-hKFymg cAQZBV card-text"
21+
>
22+
<span>
23+
<strong>
24+
Name:
25+
</strong>
26+
27+
<small>
28+
Dragon 1
29+
</small>
30+
</span>
31+
</p>
32+
<p
33+
class="sc-hKFymg cAQZBV card-text"
34+
>
35+
<span>
36+
<strong>
37+
Date:
38+
</strong>
39+
40+
<small>
41+
2023-9-9
42+
</small>
43+
</span>
44+
</p>
45+
<p
46+
class="sc-hKFymg cAQZBV card-text"
47+
>
48+
<span>
49+
<strong>
50+
Start Time:
51+
</strong>
52+
53+
<small>
54+
10:00
55+
</small>
56+
</span>
57+
</p>
58+
<p
59+
class="sc-hKFymg cAQZBV card-text"
60+
>
61+
<span>
62+
<strong>
63+
End Time:
64+
</strong>
65+
66+
<small>
67+
11:00
68+
</small>
69+
</span>
70+
</p>
71+
<p
72+
class="sc-hKFymg cAQZBV card-text"
73+
>
74+
<span>
75+
<strong>
76+
Start Location:
77+
</strong>
78+
79+
<small>
80+
Lagos
81+
</small>
82+
</span>
83+
</p>
84+
<p
85+
class="sc-hKFymg cAQZBV card-text"
86+
>
87+
<span>
88+
<strong>
89+
Destination:
90+
</strong>
91+
92+
<small>
93+
Abuja
94+
</small>
95+
</span>
96+
</p>
97+
</div>
98+
</div>
99+
</div>
100+
</div>
101+
`;

0 commit comments

Comments
 (0)