Skip to content

Commit

Permalink
[#13] Implement GET /me
Browse files Browse the repository at this point in the history
  • Loading branch information
manh-t committed Jul 4, 2023
1 parent 712b4d7 commit f62061f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/adapters/User/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { getAuth } from 'adapters/BaseAuth';

import { getUserInfo } from '.';

jest.mock('adapters/BaseAuth');

describe('UserAdapter', () => {
beforeEach(() => {
(getAuth as jest.Mock).mockImplementation(() => jest.fn());
});

afterEach(() => {
jest.clearAllMocks();
});

describe('getUserInfo', () => {
it('calls the get method from the base adapter', () => {
const expectedPath = 'me';

getUserInfo();

expect(getAuth).toHaveBeenCalledWith(expectedPath);
});
});
});
3 changes: 3 additions & 0 deletions src/adapters/User/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { getAuth } from 'adapters/BaseAuth';

export const getUserInfo = () => getAuth('me');
7 changes: 7 additions & 0 deletions src/types/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Resource } from './resource';

export interface User extends Resource {
email: string;
name: string;
avatarUrl: string;
}

0 comments on commit f62061f

Please sign in to comment.