-
Notifications
You must be signed in to change notification settings - Fork 1
Tests added for components I worked on #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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} | ||
| /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
|
||
| 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); | ||
|
|
||
|
|
||
| }); | ||
| }); | ||
areebsattar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you