forked from Lilly-Protocol/lily-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-payment.test.ts
More file actions
27 lines (26 loc) · 808 Bytes
/
Copy pathget-payment.test.ts
File metadata and controls
27 lines (26 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { describe, it, expect, vi } from 'vitest';
import { PaymentClient } from '../src/clients/payment-client';
describe('PaymentClient.get (issue #3)', () => {
it('sends GET /v1/payments/:id', async () => {
const mockClient = {
request: vi.fn(async (_req: any) => ({
status: 200,
headers: new Headers(),
data: {
id: 'pay_123',
amount: '10.00',
currency: 'USD',
status: 'completed',
},
})),
};
const client = new PaymentClient(mockClient as any);
const payment = await client.get('pay_123');
expect(mockClient.request).toHaveBeenCalledWith({
method: 'GET',
path: '/v1/payments/pay_123',
});
expect(payment.id).toBe('pay_123');
expect(payment.amount).toBe('10.00');
});
});