From 0d748033d0de3474c6b5a23e3beeb34c1ff50ba3 Mon Sep 17 00:00:00 2001 From: Bruna Campos Date: Thu, 5 Oct 2023 14:24:32 -0300 Subject: [PATCH] add integration tests to paymentmethod --- e2e/paymentMethod/get.spec.ts | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 e2e/paymentMethod/get.spec.ts diff --git a/e2e/paymentMethod/get.spec.ts b/e2e/paymentMethod/get.spec.ts new file mode 100644 index 00000000..5fd7fcd7 --- /dev/null +++ b/e2e/paymentMethod/get.spec.ts @@ -0,0 +1,49 @@ +import MercadoPago, { PaymentMethod } from '@src/index'; +import { config } from '../e2e.config'; + +describe('Testing get payment methods, get', () => { + test('should pass forward request options from get to RestClient.fetch', async () => { + const client = new MercadoPago({ accessToken: config.access_token, options: { timeout: 5000 } }); + const paymentMethod = new PaymentMethod(client); + + const paymentMethodGet = await paymentMethod.get(); + + paymentMethodGet.forEach(paymentMethod => { + expect([ + 'visa', 'elo', 'master', 'hipercard', 'pix', 'amex', 'pec', 'bolbradesco', 'account_money', 'debelo' + ]).toContain(paymentMethod.id); + }); + paymentMethodGet.forEach(paymentMethod => { + expect([ + 'account_money', 'ticket', 'bank_transfer', 'atm', 'credit_card', 'debit_card', 'prepaid_card', 'digital_currency', 'digital_wallet', 'voucher_card', 'crypto_transfer' + ]).toContain(paymentMethod.payment_type_id); + }); + paymentMethodGet.forEach(paymentMethod => { + expect([ + 'active', 'deactive', 'temporally_deactive' + ]).toContain(paymentMethod.status); + }); + paymentMethodGet.forEach(paymentMethod => { + expect([ + 'supported', 'unsupported', 'does_not_apply' + ]).toContain(paymentMethod.deferred_capture); + }); + expect(Array.isArray(paymentMethodGet)).toBe(true); + expect(paymentMethodGet[0]).toEqual(expect.objectContaining({ + id: expect.any(String), + name: expect.any(String), + payment_type_id: expect.any(String), + status: expect.any(String), + secure_thumbnail: expect.any(String), + thumbnail: expect.any(String), + deferred_capture: expect.any(String), + settings: expect.any(Array), + additional_info_needed: expect.any(Array), + min_allowed_amount: expect.any(Number), + max_allowed_amount: expect.any(Number), + accreditation_time: expect.any(Number), + financial_institutions: expect.any(Array), + processing_modes: expect.any(Array), + })); + }); +});