import { describe, it, expect } from 'vitest'; import { InMemoryPaymentsClient } from '../src/dev-client.js'; describe('InMemoryPaymentsClient', () => { describe('getByVendor', () => { it('matches case-insensitively on a substring of the vendor name', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByVendor('harbor electric'); expect(results.map((p) => p.paymentId)).toEqual(['PAY-9001']); }); it('returns the raw record with sensitive fields present (no redaction at client layer)', async () => { const client = new InMemoryPaymentsClient(); const [payment] = await client.getByVendor('Harbor Electric Co.'); expect(payment.bankAccountNumber).toBe('123456789012'); expect(payment.bankRoutingNumber).toBe('021000021'); expect(payment.cardNumber).toBe('4111111111111111'); }); it('respects opts.limit', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByVendor('', { limit: 2 }); expect(results).toHaveLength(2); }); }); describe('getByInvoice', () => { it('returns the matching payment by exact invoice number', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByInvoice('INV-3310'); expect(results.map((p) => p.paymentId)).toEqual(['PAY-9002']); expect(results[0].bankAccountNumber).toBe('987654321098'); }); it('returns an empty list for an unknown invoice', async () => { const client = new InMemoryPaymentsClient(); expect(await client.getByInvoice('INV-0000')).toEqual([]); }); it('respects opts.limit', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByInvoice('INV-3310', { limit: 0 }); expect(results).toHaveLength(0); }); }); describe('getByCheck', () => { it('returns the matching payment by exact check number', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByCheck('2089'); expect(results.map((p) => p.paymentId)).toEqual(['PAY-9003']); expect(results[0].cardNumber).toBe('340000000000009'); }); it('returns an empty list for an unknown check', async () => { const client = new InMemoryPaymentsClient(); expect(await client.getByCheck('0000')).toEqual([]); }); it('respects opts.limit', async () => { const client = new InMemoryPaymentsClient(); const results = await client.getByCheck('2089', { limit: 1 }); expect(results).toHaveLength(1); }); }); });