Skip to content

Commit

Permalink
add integration tests to paymentmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
brunacamposxx committed Oct 5, 2023
1 parent 86c25fc commit 0d74803
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions e2e/paymentMethod/get.spec.ts
Original file line number Diff line number Diff line change
@@ -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),
}));
});
});

0 comments on commit 0d74803

Please sign in to comment.