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

IT User #276

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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