UNPKG

@nicotordev/flowcl-pagos

Version:

SDK en TypeScript para integrar pagos con la API de Flow.cl de manera sencilla y segura.

65 lines 2.8 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); require("dotenv/config"); const flow_plans_1 = __importDefault(require("../clients/flow.plans")); const flowIntegration_1 = require("../test-utils/flowIntegration"); (0, flowIntegration_1.describeFlowIntegration)('Flow API Integration Tests', () => { let flowPlans; let createdPlanId; beforeAll(() => { flowPlans = new flow_plans_1.default(flowIntegration_1.flowIntegrationConfig.apiKey, flowIntegration_1.flowIntegrationConfig.secretKey, flowIntegration_1.flowIntegrationConfig.baseUrl); }); test('✅ Crea un plan de suscripción exitosamente', async () => { const planData = { planId: `test-plan-${Date.now()}`, // Evita colisiones name: 'Plan de Prueba', amount: 10000, interval: 3, }; const expected = { planId: planData.planId, }; const response = await flowPlans.create(planData); expect(response).toHaveProperty('planId'); expect(response.planId).toBe(expected.planId); createdPlanId = response.planId; }); test('✅ Obtiene los detalles del plan creado', async () => { if (!createdPlanId) throw new Error('Plan ID no disponible'); const response = await flowPlans.get(createdPlanId); expect(response).toHaveProperty('planId', createdPlanId); expect(response.name).toBe('Plan de Prueba'); }); test('✅ Lista los planes de suscripción', async () => { const response = await flowPlans.list({ start: 0, limit: 10 }); expect(response).toHaveProperty('total'); expect(response).toHaveProperty('data'); }); test('✅ Edita un plan de suscripción', async () => { if (!createdPlanId) throw new Error('Plan ID no disponible'); const editData = { planId: createdPlanId, name: 'Plan Modificado', amount: 12000, }; const expected = { planId: createdPlanId, }; const response = await flowPlans.edit(editData); expect(response).toHaveProperty('planId', createdPlanId); expect(response.planId).toBe(expected.planId); }); test('✅ Elimina un plan de suscripción', async () => { if (!createdPlanId) throw new Error('Plan ID no disponible'); const response = await flowPlans.delete(createdPlanId); expect(response).toHaveProperty('planId', createdPlanId); expect(response.status).toBe(0); // 0 indica plan eliminado }); }); //# sourceMappingURL=flowPlans.test.js.map