UNPKG

pesapal-node-sdk

Version:

Node.js SDK for integrating with Pesapal payment gateway. Provides a simple interface for processing payments, checking status, and handling callbacks.

34 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const PaymentService_1 = require("../src/services/PaymentService"); const AuthService_1 = require("../src/services/AuthService"); const HttpClient_1 = require("../src/services/HttpClient"); jest.mock('../src/services/AuthService'); jest.mock('../src/services/HttpClient'); describe('PaymentService', () => { const mockPayment = { id: 'order-123', currency: 'KES', amount: 100, description: 'Test payment' }; it('submits order successfully', async () => { const mockToken = 'test_token'; const mockAuth = { authenticate: jest.fn().mockResolvedValue(mockToken) }; const mockHttp = { post: jest.fn().mockResolvedValue({}) }; AuthService_1.AuthService.mockImplementation(() => mockAuth); HttpClient_1.HttpClient.mockImplementation(() => mockHttp); const service = new PaymentService_1.PaymentService(mockAuth, mockHttp, {}); await service.submitOrder(mockPayment); expect(mockAuth.authenticate).toHaveBeenCalled(); expect(mockHttp.post).toHaveBeenCalledWith('/v3/api/Transactions/SubmitOrderRequest', expect.objectContaining({ id: 'order-123', amount: 100 }), mockToken); }); }); //# sourceMappingURL=PaymentService.test.js.map