import { describe, it, expect, vi } from "vitest"; import { fireEvent, renderWithProviders, screen, waitFor } from "@/test/render"; import { SupplierAccountCombobox } from "./supplier-combobox"; describe("SupplierAccountCombobox", () => { it("renders the search input with its placeholder", async () => { await renderWithProviders( {}} />, { waitForButton: false, }); expect(await screen.findByPlaceholderText("Search suppliers...")).toBeInTheDocument(); }); it("disables the input when disabled", async () => { await renderWithProviders( {}} disabled />, { waitForButton: false, }, ); expect(await screen.findByPlaceholderText("Search suppliers...")).toBeDisabled(); }); it("returns the supplier's active default expense account", async () => { const onValueChange = vi.fn(); await renderWithProviders( , { waitForButton: false }, ); fireEvent.click(await screen.findByRole("button")); fireEvent.click(await screen.findByText("Default Expense Supplier")); await waitFor(() => { expect(onValueChange.mock.calls[0]?.[0]).toEqual({ id: "supplier-1", name: "Default Expense Supplier", defaultExpenseAccountId: "expense-1", }); }); }); });