-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39aaf3f
commit cb4bb88
Showing
5 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ describe('IT, cancel', () => { | |
const client = new MercadoPago({ accessToken: config.access_token }); | ||
const payment = new Payment(client); | ||
|
||
const email = createEmailTestUser(); | ||
|
||
const paymentBody = { | ||
body: { | ||
additional_info: { | ||
|
@@ -19,7 +21,7 @@ describe('IT, cancel', () => { | |
] | ||
}, | ||
payer: { | ||
email: '[email protected]', | ||
email: email, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
|
@@ -33,4 +35,10 @@ describe('IT, cancel', () => { | |
expect(cancelation).toHaveProperty('id', paymentCreate.id); | ||
expect(cancelation).toHaveProperty('status', 'cancelled'); | ||
}); | ||
|
||
function createEmailTestUser() { | ||
const random = Math.floor(Math.random() * 1000000); | ||
const email = 'test_user' + random + '@testuser.com'; | ||
return email; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ describe('IT, capture', () => { | |
const cardToken = await createCardToken(); | ||
expect(cardToken).toHaveProperty('id'); | ||
|
||
const email = createEmailTestUser(); | ||
const paymentBody = { | ||
body: { | ||
additional_info: { | ||
|
@@ -23,7 +24,7 @@ describe('IT, capture', () => { | |
] | ||
}, | ||
payer: { | ||
email: '[email protected]', | ||
email: email, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
|
@@ -82,6 +83,7 @@ describe('IT, capture', () => { | |
const cardToken = await createCardToken(); | ||
expect(cardToken).toHaveProperty('id'); | ||
|
||
const email = createEmailTestUser(); | ||
const paymentBody = { | ||
body: { | ||
additional_info: { | ||
|
@@ -95,7 +97,7 @@ describe('IT, capture', () => { | |
] | ||
}, | ||
payer: { | ||
email: '[email protected]', | ||
email: email, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
|
@@ -170,4 +172,10 @@ describe('IT, capture', () => { | |
}); | ||
return await response.json(); | ||
} | ||
|
||
function createEmailTestUser() { | ||
const random = Math.floor(Math.random() * 1000000); | ||
const email = 'test_user' + random + '@testuser.com'; | ||
return email; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ describe('IT, create', () => { | |
const client = new MercadoPago({ accessToken: config.access_token }); | ||
const payment = new Payment(client); | ||
|
||
const email = createEmailTestUser(); | ||
|
||
const body: PaymentCreateData = { | ||
body: { | ||
additional_info: { | ||
|
@@ -20,7 +22,7 @@ describe('IT, create', () => { | |
] | ||
}, | ||
payer: { | ||
email: '[email protected]', | ||
email: email, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
|
@@ -60,5 +62,79 @@ describe('IT, create', () => { | |
}), | ||
})); | ||
}); | ||
|
||
test('should create Payment when payer`s "address" field is filled', async () => { | ||
const client = new MercadoPago({ accessToken: config.access_token }); | ||
const payment = new Payment(client); | ||
|
||
const email = createEmailTestUser(); | ||
|
||
const body: PaymentCreateData = { | ||
body: { | ||
additional_info: { | ||
items: [ | ||
{ | ||
id: 'MLB2907679857', | ||
title: 'Point Mini', | ||
quantity: 1, | ||
unit_price: 58.8 | ||
} | ||
] | ||
}, | ||
payer: { | ||
email: email, | ||
address: { | ||
zip_code: '06233200', | ||
street_name: 'street_name', | ||
street_number: 123, | ||
neighborhood: 'neighborhood', | ||
city: 'city', | ||
federal_unit: 'federal_unit', | ||
}, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
payment_method_id: 'pix' | ||
} | ||
}; | ||
|
||
const response = await payment.create(body); | ||
|
||
expect(response).toHaveProperty('id'); | ||
expect(response.additional_info.items[0]).toEqual(expect.objectContaining({ | ||
id: 'MLB2907679857', | ||
title: 'Point Mini', | ||
quantity: '1', | ||
unit_price: '58.8' | ||
})); | ||
expect(response.transaction_amount).toBe(110.00); | ||
|
||
expect(response).toEqual(expect.objectContaining({ | ||
collector_id: expect.any(Number), | ||
date_created: expect.any(String), | ||
id: expect.any(Number), | ||
payment_method_id: expect.any(String), | ||
payment_type_id: expect.any(String), | ||
status: expect.any(String), | ||
status_detail: expect.any(String), | ||
transaction_amount: expect.any(Number), | ||
point_of_interaction: expect.objectContaining({ | ||
transaction_data: expect.objectContaining({ | ||
qr_code: expect.any(String), | ||
qr_code_base64: expect.any(String), | ||
ticket_url: expect.any(String), | ||
}) | ||
}), | ||
payer: expect.objectContaining({ | ||
id: expect.any(String), | ||
}), | ||
})); | ||
}); | ||
|
||
function createEmailTestUser() { | ||
const random = Math.floor(Math.random() * 1000000); | ||
const email = 'test_user' + random + '@testuser.com'; | ||
return email; | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ describe('IT, get', () => { | |
const client = new MercadoPago({ accessToken: config.access_token }); | ||
const payment = new Payment(client); | ||
|
||
const email = createEmailTestUser(); | ||
|
||
const body: PaymentCreateData = { | ||
body: { | ||
additional_info: { | ||
|
@@ -20,7 +22,7 @@ describe('IT, get', () => { | |
] | ||
}, | ||
payer: { | ||
email: '[email protected]', | ||
email: email, | ||
}, | ||
transaction_amount: 110.00, | ||
installments: 1, | ||
|
@@ -61,4 +63,10 @@ describe('IT, get', () => { | |
}), | ||
})); | ||
}); | ||
|
||
function createEmailTestUser() { | ||
const random = Math.floor(Math.random() * 1000000); | ||
const email = 'test_user' + random + '@testuser.com'; | ||
return email; | ||
} | ||
}); |