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.

30 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const AuthService_1 = require("../src/services/AuthService"); const HttpClient_1 = require("../src/services/HttpClient"); jest.mock('../src/services/HttpClient'); describe('AuthService', () => { const mockConfig = { consumerKey: 'test_key', consumerSecret: 'test_secret', apiUrl: 'https://test.api', callbackUrl: 'https://test/callback', ipnUrl: 'https://test/ipn', env: 'sandbox' }; it('authenticates successfully', async () => { const mockToken = 'test_token'; const mockPost = jest.fn().mockResolvedValue({ data: { token: mockToken } }); HttpClient_1.HttpClient.mockImplementation(() => ({ post: mockPost })); const auth = new AuthService_1.AuthService(new HttpClient_1.HttpClient(mockConfig), mockConfig); const token = await auth.authenticate(); expect(mockPost).toHaveBeenCalledWith('/api/Auth/RequestToken', { consumer_key: mockConfig.consumerKey, consumer_secret: mockConfig.consumerSecret }); expect(token).toBe(mockToken); }); }); //# sourceMappingURL=AuthService.test.js.map