import { vi, type Mock } from "vitest"; import type { BusinessPartnerRepository } from "../repository/businessPartnerRepository"; import type { CustomerAccountRepository } from "../repository/customerAccountRepository"; import type { SupplierAccountRepository } from "../repository/supplierAccountRepository"; export interface BusinessPartnerRepositoryMock extends BusinessPartnerRepository { findById: Mock; findByAddressId: Mock; findByBankAccountId: Mock; save: Mock; } export function mockBusinessPartnerRepository(): BusinessPartnerRepositoryMock { return { findById: vi.fn().mockResolvedValue(null), findByAddressId: vi.fn().mockResolvedValue(null), findByBankAccountId: vi .fn() .mockResolvedValue(null), save: vi.fn(), }; } export interface CustomerAccountRepositoryMock extends CustomerAccountRepository { findById: Mock; findByCompanyAndCode: Mock; save: Mock; } export interface SupplierAccountRepositoryMock extends SupplierAccountRepository { findById: Mock; findByCompanyAndCode: Mock; save: Mock; } export function mockSupplierAccountRepository(): SupplierAccountRepositoryMock { return { findById: vi.fn().mockResolvedValue(null), findByCompanyAndCode: vi .fn() .mockResolvedValue(null), save: vi.fn(), }; } // Injected through commands' repositoryFactory parameters. vi.mock is not an // option because vitest runs with isolate: false and shares the module cache. export function mockCustomerAccountRepository(): CustomerAccountRepositoryMock { return { findById: vi.fn().mockResolvedValue(null), findByCompanyAndCode: vi .fn() .mockResolvedValue(null), save: vi.fn(), }; }