55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { render, screen, fireEvent, waitFor } from "@testing-library/react"
|
|
import CompanyRegisterPage from "./page"
|
|
|
|
// Mocks
|
|
jest.mock("next/navigation", () => ({
|
|
useRouter: () => ({ push: jest.fn() }),
|
|
}))
|
|
|
|
jest.mock("@/lib/auth", () => ({
|
|
registerCompany: jest.fn(),
|
|
}))
|
|
|
|
jest.mock("@/lib/i18n", () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string) => key,
|
|
}),
|
|
}))
|
|
|
|
jest.mock("framer-motion", () => ({
|
|
motion: {
|
|
div: ({ children, ...props }: any) => <div {...props}>{children}</div>,
|
|
},
|
|
}))
|
|
|
|
global.ResizeObserver = class {
|
|
observe() { }
|
|
unobserve() { }
|
|
disconnect() { }
|
|
} as any
|
|
|
|
jest.mock("@/components/language-switcher", () => ({
|
|
LanguageSwitcher: () => <div>LangSwitcher</div>
|
|
}))
|
|
|
|
describe("CompanyRegisterPage", () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks()
|
|
})
|
|
|
|
it("renders step 1 fields", () => {
|
|
render(<CompanyRegisterPage />)
|
|
expect(screen.getByPlaceholderText(/register.company.form.fields.companyNamePlaceholder/i)).toBeInTheDocument()
|
|
expect(screen.getByPlaceholderText(/register.company.form.fields.cnpjPlaceholder/i)).toBeInTheDocument()
|
|
})
|
|
|
|
it("validates step 1 requirements", async () => {
|
|
render(<CompanyRegisterPage />)
|
|
fireEvent.click(screen.getByRole("button", { name: /register.company.form.actions.next/i }))
|
|
|
|
await waitFor(() => {
|
|
// Expect validation messages to appear
|
|
expect(screen.getByText(/register.company.form.errors.companyName/i)).toBeInTheDocument()
|
|
})
|
|
})
|
|
})
|