Skip to content

Commit

Permalink
feat: add profile email property
Browse files Browse the repository at this point in the history
  • Loading branch information
thxtome committed Dec 14, 2023
1 parent 7e79fc0 commit 435a802
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
11 changes: 10 additions & 1 deletion src/components/profile-setting/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ import { renderWithProviders } from '@/utils/testHelper';

import ProfileSetting from './index';

jest.mock('@/hooks/api/useGetMyProfile', () => jest.fn(() => ({
isLoading: false,
data: {
userName: 'Test POPO',
schoolName: '포포 고등학교',
grade: 1,
email: '[email protected]',
},
})));

describe('ProfileSetting', () => {
const renderProfileSetting = () => renderWithProviders(<ProfileSetting />);

it('프로필 정보를 화면에 보여준다.', () => {
renderProfileSetting();

expect(screen.getByDisplayValue('Test POPO')).toBeInTheDocument();
expect(screen.getByDisplayValue('18세')).toBeInTheDocument();
expect(screen.getByDisplayValue('포포 고등학교')).toBeInTheDocument();
expect(screen.getByDisplayValue('1학년')).toBeInTheDocument();
expect(screen.getByDisplayValue('[email protected]')).toBeInTheDocument();
Expand Down
25 changes: 18 additions & 7 deletions src/components/profile-setting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import styled from 'styled-components';

import TextField from '@/components/common/TextField';
import fixtures from '@/fixtures';
import useGetMyProfile from '@/hooks/api/useGetMyProfile';

import FixedSpinner from '../common/FixedSpinner';
import LoadingHandler from '../common/LoadingHandler';

export default function ProfileSetting() {
const { profile } = fixtures;
const {
isLoading, data = {
userName: '',
schoolName: '',
grade: 0,
email: '',
},
} = useGetMyProfile();

return (
<Container>
<TextField label="이름" value={profile.userName} readOnly />
<TextField label="나이" value="18세" readOnly />
<TextField label="학교" value={profile.schoolName} readOnly />
<TextField label="학년" value={`${profile.grade}학년`} readOnly />
<TextField label="이메일" value="[email protected]" readOnly />
<LoadingHandler isLoading={isLoading || !data} loadingComponent={<FixedSpinner type="normal" />}>
<TextField label="이름" value={data.userName} readOnly key="userName" />
<TextField label="학교" value={data.schoolName} readOnly key="schoolName" />
<TextField label="학년" value={`${data.grade}학년`} readOnly key="grade" />
<TextField label="이메일" value={data.email} readOnly />
</LoadingHandler>
</Container>
);
}
Expand Down
10 changes: 4 additions & 6 deletions src/components/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ export default function Profile() {
return (
<Container>
<LoadingHandler isLoading={isLoading || !data} loadingComponent={<FixedSpinner type="normal" />}>
<>
<ProfileHeader />
<ProfileInfo data={data as ProfileType} />
<GrayBar data-testid="graybar" />
<InviteFriends />
</>
<ProfileHeader />
<ProfileInfo data={data as ProfileType} />
<GrayBar data-testid="graybar" />
<InviteFriends />
</LoadingHandler>
</Container>
);
Expand Down
1 change: 1 addition & 0 deletions src/types/ProfileType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type ProfileType = {
reward: number,
gender: Gender,
profileImageUrl: string,
email: string,
};

export default ProfileType;

0 comments on commit 435a802

Please sign in to comment.