Skip to content

Commit

Permalink
🧪 Add: useHeader TEST
Browse files Browse the repository at this point in the history
useHeader Hooks의 userid, user, isMyAccount State에 값이 잘 들어가는지 체크
  • Loading branch information
Clzzi committed Nov 14, 2021
1 parent 4d6cef5 commit ea7c54e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion __mocks__/data/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const MOCK_TOTALUSERS: ITotalUserRankResponse = {
totalContributions: 2100,
user: {
id: 'user_id_value',
name: 'Clzzi',
name: '손민재',
},
userImage: 'http://test.jpg',
},
Expand Down
17 changes: 17 additions & 0 deletions hooks/header/useHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { customRenderHook } from 'util/customRenderHook';
import { MOCK_INFO } from '__mocks__/data/auth';
import useHeader from './useHeader';

describe('useHeader Testing', () => {
beforeEach(() => {
localStorage.setItem('access_token', 'testToken');
});
it('Return Value Correctly', async () => {
const { result, waitForNextUpdate } = customRenderHook(() => useHeader());
await waitForNextUpdate();
expect(result.current.userId).toEqual(['손민재', 'USER']);
await waitForNextUpdate();
expect(result.current.user).toEqual(MOCK_INFO.data);
expect(result.current.isMyAccount).toEqual(true);
});
});

0 comments on commit ea7c54e

Please sign in to comment.