import { ok } from "@tailor-platform/erp-kit/core"; import { vi } from "vitest"; import type { OrganizationQueries } from "../module"; export type Department = NonNullable< Awaited>["value"]["department"] >; export type Site = NonNullable< Awaited>["value"]["site"] >; export type Company = NonNullable< Awaited>["value"]["company"] >; export const mockOrganizationQueries = (store: { departments?: Department[]; sites?: Site[]; companies?: Company[]; }) => ({ getDepartment: vi.fn((_db, input) => Promise.resolve( ok({ department: store.departments?.find((department) => "id" in input ? department.id === input.id : department.code === input.code && department.companyId === input.companyId, ) ?? null, }), ), ), getSite: vi.fn((_db, input) => Promise.resolve(ok({ site: store.sites?.find((site) => site.id === input.id) ?? null })), ), getCompany: vi.fn((_db, input) => Promise.resolve( ok({ company: store.companies?.find((company) => company.id === input.id) ?? null }), ), ), });