@vulog/aima-payment
Version:
Payment management module for the AIMA platform. This module provides functionality to handle payments, setup intents, payment methods, and trip payments.
42 lines (34 loc) • 1.12 kB
text/typescript
import { describe, test, vi, expect } from 'vitest';
import { payATrip } from './payATrip';
import { Client } from '@vulog/aima-client';
describe('payATrip', () => {
const postMock = vi.fn();
const client = {
post: postMock,
clientOptions: {
fleetId: 'FLEET_ID',
},
} as unknown as Client;
const pay = {
payATrip,
};
const payATripSpy = vi.spyOn(pay, 'payATrip');
test('Call OK with tripId and payment method', async () => {
const tripId = 'trip1';
const body = {
amountValue: 100,
amountType: 'FIXED' as const,
};
const paymentResponse = {
id: 'payment1',
status: 'PAID',
amount: 100,
tripId,
};
postMock.mockResolvedValue({ data: paymentResponse });
await pay.payATrip(client, tripId, body);
expect(payATripSpy).toHaveBeenCalledWith(client, tripId, body);
expect(payATripSpy).toHaveBeenCalledTimes(1);
expect(payATripSpy).toHaveReturnedWith(Promise.resolve(paymentResponse));
});
});