xtablo-source/ui/src/components/BrandButtons/LoginWithGoogle.test.tsx
Arthur Belleville 374a1ec4b8
Fix lint
2025-10-10 11:10:28 +02:00

40 lines
1.1 KiB
TypeScript

import { fireEvent, render, screen } from "@testing-library/react";
import { LoginWithGoogle } from "@ui/components/BrandButtons/LoginWithGoogle";
import { useLoginGoogle } from "@ui/hooks/auth";
import { vi } from "vitest";
vi.mock("../../hooks/auth", () => ({
useLoginGoogle: vi.fn(),
}));
describe("LoginWithGoogle", () => {
it("renders the Google login button", () => {
const mockLoginWithGoogle = vi.fn();
(useLoginGoogle as ReturnType<typeof vi.fn>).mockReturnValue({
loginWithGoogle: mockLoginWithGoogle,
});
render(<LoginWithGoogle />);
const button = screen.getByRole("button", {
name: /Continuer avec Google/i,
});
expect(button).toBeInTheDocument();
});
it("calls loginWithGoogle when clicked", () => {
const mockLoginWithGoogle = vi.fn();
(useLoginGoogle as ReturnType<typeof vi.fn>).mockReturnValue({
loginWithGoogle: mockLoginWithGoogle,
});
render(<LoginWithGoogle />);
const button = screen.getByRole("button", {
name: /Continuer avec Google/i,
});
fireEvent.click(button);
expect(mockLoginWithGoogle).toHaveBeenCalledTimes(1);
});
});