Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Point of Interaction to the root and Address to Payer #297

Merged
38 changes: 5 additions & 33 deletions e2e/cardToken/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import MercadoPago, { CardToken, Customer, CustomerCard } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('IT, create card token', () => {
test('should make a request and return created card token id', async () => {
const client = new MercadoPago({ accessToken: config.test_access_token });
Expand All @@ -9,12 +12,12 @@ describe('IT, create card token', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -42,35 +45,4 @@ describe('IT, create card token', () => {
security_code_length: expect.any(Number),
}));
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
11 changes: 3 additions & 8 deletions e2e/customer/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, create', () => {
test('should create a client and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, create', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
first_name: 'Jhon',
last_name: 'Doe',
phone: {
Expand All @@ -36,7 +37,7 @@ describe('IT customer, create', () => {
const createCustomer = await customer.create({ body });
expect(createCustomer).toHaveProperty('status', 'active');
expect(createCustomer).toEqual(expect.objectContaining({
email: email,
email,
first_name: 'Jhon',
last_name: 'Doe',
date_registered: '2023-10-20T11:37:30.000-04:00',
Expand Down Expand Up @@ -77,10 +78,4 @@ describe('IT customer, create', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer).toHaveProperty('id', removeCustomer.id);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
9 changes: 2 additions & 7 deletions e2e/customer/get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, get', () => {
test('should get a client and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, get', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand All @@ -23,10 +24,4 @@ describe('IT customer, get', () => {
const removeCustomer = await customer.remove({ customerId: customerGet.id });
expect(removeCustomer).toHaveProperty('id', removeCustomer.id);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
10 changes: 2 additions & 8 deletions e2e/customer/remove.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, remove', () => {
test('should delete a customer and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, remove', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand All @@ -30,12 +31,5 @@ describe('IT customer, remove', () => {
address: expect.any(Object),
date_last_updated: expect.any(String),
}));

});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
9 changes: 2 additions & 7 deletions e2e/customer/update.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, update', () => {
test('should update a customer and match response object', async () => {
Expand All @@ -8,7 +9,7 @@ describe('IT customer, update', () => {

const email = createEmailTestUser();
const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand Down Expand Up @@ -40,10 +41,4 @@ describe('IT customer, update', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer).toHaveProperty('id', removeCustomer.id);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer cards, create', () => {
test('should create customer card and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer cards, create', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -59,35 +60,4 @@ describe('Testing customer cards, create', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer card, get', () => {
test('should get customer card and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer card, get', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -62,35 +63,4 @@ describe('Testing customer card, get', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer card, get', () => {
test('should get list of cards and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer card, get', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -63,35 +64,4 @@ describe('Testing customer card, get', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
Loading