Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

1 import {describe,expect,it,vi} from 'vitest';import {PostgresOperationsRepository} from './postgres-operations-repository';
2 describe('PostgresOperationsRepository',()=>{it('queries only the requested tenant and maps IRR safely',async()=>{const query=vi.fn().mockResolvedValue({rows:[{tenant_id:'t1',state:'SETTLED',amount_irr:'1200'}]});const repo=new PostgresOperationsRepository({query});await expect(repo.listPayments('t1')).resolves.toEqual([{tenantId:'t1',state:'SETTLED',amountIrr:1200}]);expect(query).toHaveBeenCalledWith(expect.stringContaining('tenant_id = $1'),['t1'])});it('rejects unsafe bigint values instead of truncating money',async()=>{const query=vi.fn().mockResolvedValue({rows:[{tenant_id:'t1',state:'SETTLED',amount_irr:'9007199254740992'}]});const repo=new PostgresOperationsRepository({query});await expect(repo.listPayments('t1')).rejects.toThrow('unsafe IRR')})});