Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/components/Footer/Footer.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Footer from "./Footer.jsx";
import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";

describe("Footer", () => {
it("renders the footer at the bottom of the page with each address property as a list item", () => {
const details = [
"123 Fake Street, London, E1 4UD",
"hello@fakehotel.com",
"0123 456789",
];

render(<Footer details={details} />);

const footer = screen.getByRole("contentinfo");
const listItems = screen.getAllByRole("listitem");

expect(footer).toBeTruthy();
expect(listItems).toHaveLength(details.length);

details.forEach((detail, index) => {
expect(listItems[index]).toHaveTextContent(detail);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see some tests showing up here. These look great :)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

});
});
26 changes: 12 additions & 14 deletions src/components/SearchResult/SearchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ function SearchResult() {
"day"
);
return (
<>
<TableBody
key={book.id}
id={book.id}
title={book.title}
firstName={book.firstName}
surName={book.surname}
email={book.email}
roomId={book.roomId}
checkInDate={book.checkInDate}
checkOutDate={book.checkOutDate}
stayNights={stayNightsTotal}
/>
</>
<TableBody
key={book.id}
id={book.id}
title={book.title}
firstName={book.firstName}
surName={book.surname}
email={book.email}
roomId={book.roomId}
checkInDate={book.checkInDate}
checkOutDate={book.checkOutDate}
stayNights={stayNightsTotal}
/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a matter of personal prefecence to an extent but, I would personally just give the whole book object to TableBody so it can do what it needs to do

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to look this up after main tickets are done

);
})}
</tbody>
Expand Down
29 changes: 29 additions & 0 deletions src/components/SearchResult/SearchResult.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import SearchResult from "./SearchResult";
import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";

describe("Table", () => {
it("renders a column for each booking attribute in the table header", () => {
render(<SearchResult />);

const tableHead = screen.getByRole("table");
const tableHeaders = screen.getAllByRole("columnheader");

expect(tableHead).toBeTruthy();
expect(tableHeaders).toHaveLength(9);


});

it("renders more than one booking in the table body", () => {
render(<SearchResult />);

const tableBody = screen.getByRole("table");
const tableRows = screen.getAllByRole("row");

expect(tableBody).toBeTruthy();
expect(tableRows.length).toBeGreaterThan(1);


});
});
2 changes: 1 addition & 1 deletion src/components/SearchResult/TableHead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function TableHead() {
<th>Room id</th>
<th>Check in date</th>
<th>Check out date</th>
<th>Total Nights to Stay</th>
<th>Number of Nights</th>
</tr>
</>
);
Expand Down