Skip to content

Commit

Permalink
fix: review반영
Browse files Browse the repository at this point in the history
  • Loading branch information
jun0811 committed Sep 4, 2024
1 parent cda98cb commit 61a0eaa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ describe('CreateMemberForm', () => {

it('validates nickname field', async () => {
render(<TestWrapper />)

const nicknameInput = screen.getByPlaceholderText('닉네임을 입력해주세요')

// 닉네임이 너무 짧은 경우
await userEvent.type(nicknameInput, 'a')

await waitFor(() => {
expect(screen.getByText('닉네임을 2자 이상 입력해주세요')).toBeInTheDocument()
})

await userEvent.clear(nicknameInput)
await userEvent.type(nicknameInput, 'test')
await waitFor(() => {
expect(screen.queryByText('닉네임을 2자 이상 입력해세요')).not.toBeInTheDocument()
})
})

it('validates contact field', async () => {
Expand All @@ -51,9 +55,14 @@ describe('CreateMemberForm', () => {
const addressInput = screen.getByPlaceholderText('연락처를 입력해주세요')

// 잘못된 전화번호 형식
userEvent.type(addressInput, 'abcdefghij')
await userEvent.type(addressInput, 'test')
await waitFor(() => {
expect(screen.getByText('올바른 전화번호를 입력해주세요')).toBeInTheDocument()
})
await userEvent.clear(addressInput)
await userEvent.type(addressInput, '01000000000')
await waitFor(() => {
expect(screen.queryByText('올바른 전화번호를 입력해주세요')).not.toBeInTheDocument()
})
})
})
File renamed without changes.
6 changes: 3 additions & 3 deletions src/app/signup/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use client'

import CreateMemberForm from '@/components/member/CreateMemberForm'
import CreateMemberForm from '@/app/signup/_components/CreateMemberForm'
import Footer from '@/components/shared/\bFooter'
import BackButton from '@/components/shared/BackButton'
import Header from '@/components/shared/Header/indes'
import { useSignUpForm } from '@/features/member/hooks/useCreateMeberForm'
import { useSignUpFormHook } from '@/features/member/hooks/useCreateMeberForm'
import React from 'react'

const SignUpPage = () => {
const { form, handleSubmit } = useSignUpForm()
const { form, handleSubmit } = useSignUpFormHook()
return (
<div className="flex min-h-screen flex-col">
<Header left={<BackButton />} />
Expand Down
2 changes: 1 addition & 1 deletion src/features/member/hooks/useCreateMeberForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createMemberFormSchema = z.object({
export type CreateMemberFormDataType = z.infer<typeof createMemberFormSchema>

// useSignupForm 훅 정의
export const useSignUpForm = () => {
export const useSignUpFormHook = () => {
const form = useForm<CreateMemberFormDataType>({
resolver: zodResolver(createMemberFormSchema),
mode: 'onChange',
Expand Down

0 comments on commit 61a0eaa

Please sign in to comment.