import { ok } from "@tailor-platform/erp-kit/core";
import { vi } from "vitest";
import type { OrganizationQueries } from "../module";

export type Company = NonNullable<
  Awaited<ReturnType<OrganizationQueries["getCompany"]>>["value"]["company"]
>;

export const mockOrganizationQueries = (store: { companies?: Company[] }) => ({
  getCompany: vi.fn<OrganizationQueries["getCompany"]>((_db, input) =>
    Promise.resolve(
      ok({ company: store.companies?.find((company) => company.id === input.id) ?? null }),
    ),
  ),
});
