Skip to content
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

refactor: Replacing img selectors in tests II #116

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion __tests__/components/Forms/SigninButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("render the button", () => {
Facebook
</SignInButton>
);
const image = screen.getByRole("img");
const image = screen.getByLabelText("third-part-service-login");
expect(image).toBeInTheDocument();
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Inputs/BBInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, screen } from "@testing-library/react";
describe("Black Burger input with image", () => {
test("render image", () => {
render(<BBInput src="/test" alt="test" type="test" placeholder="test" />);
const image = screen.getByRole("img");
const image = screen.getByLabelText("input icon");
expect(image).toBeInTheDocument();
});

Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Inputs/InputPassword.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { fireEvent, render, screen } from "@testing-library/react";
describe("Render input password", () => {
test("render image", () => {
render(<InputPassword />);
const image = screen.getByRole("img", { name: "icon" });
const image = screen.getByAltText("senha");
expect(image).toBeInTheDocument();
});

Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/Navigation/ArrowBackToHome.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ const pushMock = jest.fn();
describe("User navigation to home page", () => {
test("render image", () => {
render(<ArrowBackToHome />);
const image = screen.getByRole("img");
const image = screen.getByAltText("voltar");
expect(image).toBeInTheDocument();
});

test("should have cursor pointer", () => {
render(<ArrowBackToHome />);
const image = screen.getByRole("img");
const image = screen.getByAltText("voltar");
expect(image).toHaveClass("cursor-pointer");
});

test("navigation after click", () => {
(useRouter as jest.Mock).mockReturnValue({ push: pushMock });
render(<ArrowBackToHome />);
fireEvent.click(screen.getByRole("img"));
fireEvent.click(screen.getByAltText("voltar"));
expect(pushMock).toHaveBeenCalledWith("/home");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("User Button Navigation UI", () => {

test("render menu icon", () => {
render(<UserButtoNavigation />);
const icon = screen.getByRole("img");
const icon = screen.getByAltText("user");
expect(icon).toBeInTheDocument();
});
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Surfaces/FeatureCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Featured card", () => {
productPrice="1000"
/>
);
const img = screen.getByRole("img");
const img = screen.getByLabelText("product-image");
expect(img).toBeInTheDocument();
expect(img).toHaveAttribute("alt", "alt test");
expect(img).toHaveAttribute("src", "/test.svg");
Expand Down
2 changes: 1 addition & 1 deletion src/components/Forms/SignInForm/SignInButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { signInresult } from "@/services/auth/signin";
import { signIn } from "next-auth/react";
import Image from "next/image";
import { useRouter } from "next/navigation";

Expand Down Expand Up @@ -55,6 +54,7 @@ export default function SignInButton({
height={0}
sizes="100vw"
className="w-6 h-6"
aria-label="third-part-service-login"
/>

<button className="font-lilita text-gray-bb-100 drop-shadow-bb-1 cursor-pointer">
Expand Down
1 change: 1 addition & 0 deletions src/components/Inputs/Input/BBInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function BBInput({
height={0}
sizes="100vw"
className="w-6 h-6 m-2 drop-shadow-bb-1"
aria-label="input icon"
/>

<input
Expand Down
1 change: 0 additions & 1 deletion src/components/Inputs/Input/InputPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default function InputPassword({ register }: TInputProps) {
height={0}
sizes="100vw"
className="w-6 h-6 m-2 drop-shadow-bb-1"
aria-label="icon"
/>

<input
Expand Down
1 change: 1 addition & 0 deletions src/components/Surfaces/FeaturedCard/FeaturedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default function FeaturedCard({
className="
absolute -left-11 bottom-1 z-10 h-full max-h-[114px] w-full max-w-[110px]
"
aria-label="product-image"
/>
<div
className="
Expand Down
Loading