forked from ShelterTechSF/askdarcel-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Jest + React Testing Library π§βπ¬ (#129)
- Loading branch information
1 parent
4ae3cf6
commit a9fe824
Showing
14 changed files
with
11,978 additions
and
8,153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ yarn.lock | |
|
||
# Built Visual Studio Code Extensions | ||
*.vsix | ||
|
||
# jest | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 0 additions & 130 deletions
130
app/components/listing/__tests__/RelativeOpeningTimes.spec.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
import { render, screen } from "@testing-library/react"; | ||
import "@testing-library/jest-dom"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
import { ServiceCard } from "../../ui/Cards/ServiceCard"; | ||
|
||
describe("<ServiceCard />", () => { | ||
const validService = { | ||
id: 2, | ||
name: "Test Service", | ||
long_description: "This valuable service does things", | ||
}; | ||
|
||
it("checks a valid user should render the appropriate fields in the right place", () => { | ||
render(<ServiceCard service={validService} />, { wrapper: BrowserRouter }); | ||
expect(screen.getByRole("heading")).toHaveTextContent("Test Service"); | ||
expect(screen.getByTestId("service-card-description")).toHaveTextContent( | ||
validService.long_description | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import { Service } from "models"; | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { Service } from "../../../models"; | ||
import styles from "./ServiceCard.module.scss"; | ||
|
||
export const ServiceCard = ({ service }: { service: Service }) => { | ||
type ServiceCardProps = Pick<Service, "id" | "name" | "long_description">; | ||
|
||
export const ServiceCard = ({ service }: { service: ServiceCardProps }) => { | ||
const { id, name, long_description } = service; | ||
|
||
return ( | ||
<Link to={{ pathname: `/services/${id}` }} className={styles.serviceCard}> | ||
<h3 className={styles.header}>{name}</h3> | ||
<p className={styles.description}>{long_description}</p> | ||
<p data-testid="service-card-description" className={styles.description}> | ||
{long_description} | ||
</p> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// import { removeAsterisksAndHashes } from "./strings"; | ||
import { removeAsterisksAndHashes } from "./strings"; | ||
|
||
// describe("removeAsterisksAndHashes", () => { | ||
// it("removes # and *", () => { | ||
// const str = `# **Service Contact Information:**\n# **Another Heading:**`; | ||
describe("removeAsterisksAndHashes", () => { | ||
it("removes # and *", () => { | ||
const str = `# **Service Contact Information:**\n# **Another Heading:**`; | ||
const actual = removeAsterisksAndHashes(str); | ||
const expected = ` Service Contact Information:\n Another Heading:`; | ||
|
||
// const actual = removeAsterisksAndHashes(str); | ||
// const expected = ` Service Contact Information:\n Another Heading:`; | ||
// expect(actual).to.equal(expected); | ||
// }); | ||
// }); | ||
expect(actual).toBe(expected); | ||
}); | ||
}); |
Oops, something went wrong.