Skip to content

Commit

Permalink
Merge pull request #276 from mercadopago/feature/user-integration-test
Browse files Browse the repository at this point in the history
IT User
  • Loading branch information
lucmkz authored Oct 16, 2023
2 parents 8cbb21f + 030abd9 commit 6db72b8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
42 changes: 42 additions & 0 deletions e2e/user/get.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import MercadoPago, { User } from '@src/index';
import { config } from '../e2e.config';

describe('Testing User, get method', () => {
test('should return user data with success', async () => {
const client = new MercadoPago({ accessToken: config.access_token, options: { timeout: 5000 } });
const user = new User(client);

const getUser = await user.get();

expect(getUser).toHaveProperty('id');
expect(getUser).toEqual(expect.objectContaining({
id: expect.any(Number),
nickname: expect.any(String),
registration_date: expect.any(String),
first_name: expect.any(String),
last_name: expect.any(String),
gender: expect.any(String),
country_id: expect.any(String),
email: expect.any(String),
identification: expect.any(Object),
phone: expect.any(Object),
address: expect.any(Object),
alternative_phone: expect.any(Object),
user_type: expect.any(String),
tags: expect.any(Array),
points: expect.any(Number),
site_id: expect.any(String),
permalink: expect.any(String),
seller_experience: expect.any(String),
bill_data: expect.any(Object),
seller_reputation: expect.any(Object),
buyer_reputation: expect.any(Object),
status: expect.any(Object),
secure_email: expect.any(String),
company: expect.any(Object),
credit: expect.any(Object),
context: expect.any(Object),
registration_identifiers: expect.any(Array),
}));
});
});
4 changes: 2 additions & 2 deletions src/clients/user/get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { RestClient } from '@utils/restClient';

import type { UserGetClient, UserResponse } from './types';

export default function get({ config }: UserGetClient): Promise<UserResponse[]> {
return RestClient.fetch<UserResponse[]>(
export default function get({ config }: UserGetClient): Promise<UserResponse> {
return RestClient.fetch<UserResponse>(
'/users/me',
{
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/clients/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class User {
*
* @see {@link https://github.com/mercadopago/sdk-nodejs/blob/master/examples/user/get/get.ts Usage Example }.
*/
get(userGetData: UserGetData = {}): Promise<UserResponse[]> {
get(userGetData: UserGetData = {}): Promise<UserResponse> {
const { requestOptions } = userGetData;
this.config.options = { ...this.config.options, ...requestOptions };
return get({ config: this.config });
Expand Down

0 comments on commit 6db72b8

Please sign in to comment.