Skip to content
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
27 changes: 14 additions & 13 deletions src/app/(user)/mypage/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const renderWithQueryClient = async (component: React.ReactElement) => {
await act(async () => {
renderResult = render(
<QueryClientProvider client={testQueryClient}>
<AuthProvider>
<AuthProvider hasRefreshToken={false}>
<ModalProvider>{component}</ModalProvider>
</AuthProvider>
</QueryClientProvider>,
Expand Down Expand Up @@ -84,8 +84,9 @@ describe('마이 페이지 테스트', () => {
test('설정 화면이 올바르게 표시되는지 테스트', async () => {
await renderWithQueryClient(<MyPage />);

expect(await screen.findByText('알림 받기')).toBeInTheDocument();
expect(screen.getByText('로그아웃')).toBeInTheDocument();
// expect(await screen.findByText('알림 받기')).toBeInTheDocument();
expect(await screen.findByText('로그아웃')).toBeInTheDocument();
// expect(screen.getByText('로그아웃')).toBeInTheDocument();
expect(screen.getByText('회원탈퇴')).toBeInTheDocument();
});

Expand All @@ -102,19 +103,19 @@ describe('마이 페이지 테스트', () => {
});
});

test('알림 설정이 정상적으로 동작하는지 테스트', async () => {
const user = userEvent.setup();
// test('알림 설정이 정상적으로 동작하는지 테스트', async () => {
// const user = userEvent.setup();

const updateNotificationSpy = jest.spyOn(API.userService, 'updateMyNotification');
await renderWithQueryClient(<MyPage />);
// const updateNotificationSpy = jest.spyOn(API.userService, 'updateMyNotification');
// await renderWithQueryClient(<MyPage />);

const notificationButton = await screen.findByRole('button', { name: '알림 받기' });
await user.click(notificationButton);
// const notificationButton = await screen.findByRole('button', { name: '알림 받기' });
// await user.click(notificationButton);

await waitFor(() => {
expect(updateNotificationSpy).toHaveBeenCalled();
});
});
// await waitFor(() => {
// expect(updateNotificationSpy).toHaveBeenCalled();
// });
// });

test('로그아웃이 정상적으로 동작하는지 테스트', async () => {
const user = userEvent.setup();
Expand Down
12 changes: 6 additions & 6 deletions src/components/pages/user/mypage/mypage-setting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
'use client';
import { useLogout, useWithdraw } from '@/hooks/use-auth';
import { useUpdateMyNotification } from '@/hooks/use-user/use-user-notification';
// import { useUpdateMyNotification } from '@/hooks/use-user/use-user-notification';
import { User } from '@/types/service/user';

import { MyPageActionButton, MyPageToggleButton } from '../mypage-setting-button';
import { MyPageActionButton, MyPageToggleButton as _ } from '../mypage-setting-button';

interface Props {
user: User;
}

export const MyPageSetting = ({ user }: Props) => {
const { mutate } = useUpdateMyNotification();
export const MyPageSetting = ({ user: _ }: Props) => {
// const { mutate } = useUpdateMyNotification();
const logout = useLogout();
const withdraw = useWithdraw();

return (
<section className='bg-mono-white flex flex-col gap-3 px-3 py-6'>
<MyPageToggleButton
{/* <MyPageToggleButton
value={user.isNotificationEnabled}
onClick={() => mutate({ isNotificationEnabled: !user.isNotificationEnabled })}
>
알림 받기
</MyPageToggleButton>
</MyPageToggleButton> */}
<MyPageActionButton onClick={logout}>로그아웃</MyPageActionButton>
<MyPageActionButton onClick={withdraw}>회원탈퇴</MyPageActionButton>
</section>
Expand Down