Skip to content

Commit

Permalink
Add new test condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zehguilherme committed Sep 5, 2023
1 parent ba791c8 commit e27a7b0
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion web/src/components/Header/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("Home page", () => {
expect(xMarkElement).toBeVisible();
});

it("should render 4 links with their correctly styles", () => {
it("should render 4 links (one for every section)", () => {
render(<Header />);

const links = screen.getAllByRole("link");
Expand All @@ -68,5 +68,27 @@ describe("Home page", () => {
expect(link).toBeInTheDocument();
});
});

it("should check if every link adds a anchor to the url when clicked", async () => {
const user = userEvent.setup();

render(<Header />);

const homeLink = screen.getByText("Home");
await user.click(homeLink);
expect(homeLink).toHaveAttribute("href", "/");

const projectsLink = screen.getByText("Projetos");
await user.click(projectsLink);
expect(projectsLink).toHaveAttribute("href", "#projetos");

const aboutLink = screen.getByText("Sobre");
await user.click(aboutLink);
expect(aboutLink).toHaveAttribute("href", "#sobre");

const contactLink = screen.getByText("Contato");
await user.click(contactLink);
expect(contactLink).toHaveAttribute("href", "#contato");
});
});
});

0 comments on commit e27a7b0

Please sign in to comment.