-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from tteokbokki-master/Weekly
Test/#154 ν μ€νΈμ½λ μμ±
- Loading branch information
Showing
2 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { renderWithProviders } from '@/__test__/test-utils'; | ||
import { server } from '@/mocks/server'; | ||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
import ApplyPage from '../ApplyPage'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { fireEvent, screen, act } from '@testing-library/react'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
describe('ApplyPage μ»΄ν¬λνΈ ν μ€νΈ', () => { | ||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
const renderApplyForm = () => { | ||
return renderWithProviders( | ||
<QueryClientProvider client={queryClient}> | ||
<ApplyPage /> | ||
</QueryClientProvider>, | ||
); | ||
}; | ||
|
||
it('λͺ¨λ νλλ₯Ό μ¬λ°λ₯΄κ² μ λ ₯ν κ²½μ° λ²νΌμ΄ μ μμ μΌλ‘ ν΄λ¦λλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ.'); | ||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: λμ κ΄μμ μ μ±κ΅¬ κΆλ)'); | ||
const phoneNumberInput = screen.getByPlaceholderText('λ²νΈλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: 010-0000-0000)'); | ||
const motivationInput = screen.getByPlaceholderText('μ§μλκΈ°λ₯Ό μ λ ₯ν΄μ£ΌμΈμ'); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(addressInput, { target: { value: 'λμ κ΄μμ μ μ±κ΅¬ κΆλ' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '010-1234-1234' } }); | ||
fireEvent.change(motivationInput, { target: { value: 'μλ ' } }); | ||
}); | ||
|
||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
await act(async () => { | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
expect(submitButton).toBeEnabled(); | ||
}); | ||
|
||
it('μλͺ»λ μ νλ²νΈ νμμ μ λ ₯νλ©΄ μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ.'); | ||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: λμ κ΄μμ μ μ±κ΅¬ κΆλ)'); | ||
const phoneNumberInput = screen.getByPlaceholderText('λ²νΈλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: 010-0000-0000)'); | ||
const motivationInput = screen.getByPlaceholderText('μ§μλκΈ°λ₯Ό μ λ ₯ν΄μ£ΌμΈμ'); | ||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(addressInput, { target: { value: 'λμ κ΄μμ μ μ±κ΅¬ κΆλ' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '1234' } }); | ||
fireEvent.change(motivationInput, { target: { value: 'μλ ' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = screen.getByText('μ¬λ°λ₯Έ μ νλ²νΈ νμμ΄ μλλλ€. (μ: 010-0000-0000)'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it('μ΄λ¦μ μ λ ₯νμ§ μμΌλ©΄ μ ν¨μ± μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: λμ κ΄μμ μ μ±κ΅¬ κΆλ)'); | ||
const phoneNumberInput = screen.getByPlaceholderText('λ²νΈλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: 010-0000-0000)'); | ||
const motivationInput = screen.getByPlaceholderText('μ§μλκΈ°λ₯Ό μ λ ₯ν΄μ£ΌμΈμ'); | ||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(addressInput, { target: { value: 'λμ κ΄μμ μ μ±κ΅¬ κΆλ' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '010-1234-5678' } }); | ||
fireEvent.change(motivationInput, { target: { value: 'μλ ' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = await screen.findByText('μ΄λ¦μ(λ₯Ό) μ λ ₯ν΄μ£ΌμΈμ!'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it('μ£Όμλ₯Ό μ λ ₯νμ§ μμΌλ©΄ μ ν¨μ± μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ.'); | ||
const phoneNumberInput = screen.getByPlaceholderText('λ²νΈλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: 010-0000-0000)'); | ||
const motivationInput = screen.getByPlaceholderText('μ§μλκΈ°λ₯Ό μ λ ₯ν΄μ£ΌμΈμ'); | ||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '010-1234-5678' } }); | ||
fireEvent.change(motivationInput, { target: { value: 'μ±μ€ν μνκ² μ΅λλ€.' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = await screen.findByText('μ£Όμμ(λ₯Ό) μ λ ₯ν΄μ£ΌμΈμ!'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it('λ²νΈλ₯Ό μ λ ₯νμ§ μμΌλ©΄ μ ν¨μ± μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ.'); | ||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: λμ κ΄μμ μ μ±κ΅¬ κΆλ)'); | ||
const motivationInput = screen.getByPlaceholderText('μ§μλκΈ°λ₯Ό μ λ ₯ν΄μ£ΌμΈμ'); | ||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(addressInput, { target: { value: 'λμ κ΄μμ μ μ±κ΅¬ κΆλ' } }); | ||
fireEvent.change(motivationInput, { target: { value: 'νμ΄' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = await screen.findByText('λ²νΈμ(λ₯Ό) μ λ ₯ν΄μ£ΌμΈμ!'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it('μ§μλκΈ°λ₯Ό μ λ ₯νμ§ μμΌλ©΄ μ ν¨μ± μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderApplyForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯ν΄μ£ΌμΈμ.'); | ||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: λμ κ΄μμ μ μ±κ΅¬ κΆλ)'); | ||
const phoneNumberInput = screen.getByPlaceholderText('λ²νΈλ₯Ό μ λ ₯ν΄μ£ΌμΈμ (μ: 010-0000-0000)'); | ||
const submitButton = screen.getByRole('button', { name: 'μ§μνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(addressInput, { target: { value: 'λμ κ΄μμ μ μ±κ΅¬ κΆλ' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '010-1234-5678' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = await screen.findByText('μ§μλκΈ°μ(λ₯Ό) μ λ ₯ν΄μ£ΌμΈμ!'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { renderWithProviders } from '@/__test__/test-utils'; | ||
import { server } from '@/mocks/server'; | ||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
import Resume from '../Resume'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { fireEvent, screen, act } from '@testing-library/react'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
describe('Resume μ»΄ν¬λνΈ ν μ€νΈ', () => { | ||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
const renderResumeForm = () => { | ||
return renderWithProviders( | ||
<QueryClientProvider client={queryClient}> | ||
<Resume /> | ||
</QueryClientProvider>, | ||
); | ||
}; | ||
|
||
it('λͺ¨λ νλλ₯Ό μ¬λ°λ₯΄κ² μ λ ₯ν κ²½μ° λ²νΌμ΄ λλ¦°λ€', async () => { | ||
renderResumeForm(); | ||
|
||
const nameInput = screen.getByPlaceholderText('μ΄λ¦μ μ λ ₯νμΈμ.'); | ||
const addressInput = screen.getByPlaceholderText('μ£Όμλ₯Ό μ λ ₯νμΈμ.'); | ||
const phoneNumberInput = screen.getByPlaceholderText('010-0000-0000 νμμ λ²νΈλ₯Ό μ λ ₯νμΈμ.'); | ||
const careerInput = screen.getByPlaceholderText('κ²½λ ₯μ μ λ ₯νμΈμ.'); | ||
const introductionTextarea = screen.getByPlaceholderText('μκΈ°μκ°λ₯Ό μ λ ₯νμΈμ.'); | ||
|
||
await act(async () => { | ||
fireEvent.change(nameInput, { target: { value: 'μ΄μ¬μ©' } }); | ||
fireEvent.change(addressInput, { target: { value: 'μμΈμ κ°λ¨κ΅¬' } }); | ||
fireEvent.change(phoneNumberInput, { target: { value: '010-1234-5678' } }); | ||
fireEvent.change(careerInput, { target: { value: '3λ ' } }); | ||
fireEvent.change(introductionTextarea, { target: { value: 'λ μ€' } }); | ||
}); | ||
|
||
const submitButton = screen.getByRole('button', { name: 'μ μΆνκΈ°' }); | ||
await act(async () => { | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
expect(submitButton).toBeEnabled(); | ||
}); | ||
|
||
it('μλͺ»λ μ νλ²νΈ νμμ μ λ ₯νλ©΄ μλ¬ λ©μμ§λ₯Ό νμνλ€', async () => { | ||
renderResumeForm(); | ||
|
||
const phoneNumberInput = screen.getByPlaceholderText('010-0000-0000 νμμ λ²νΈλ₯Ό μ λ ₯νμΈμ.'); | ||
const submitButton = screen.getByRole('button', { name: 'μ μΆνκΈ°' }); | ||
|
||
await act(async () => { | ||
fireEvent.change(phoneNumberInput, { target: { value: '1234' } }); | ||
fireEvent.click(submitButton); | ||
}); | ||
|
||
const errorMessage = await screen.findByText('μ¬λ°λ₯Έ μ νλ²νΈ νμμ΄ μλλλ€. (μ: 010-0000-0000)'); | ||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
}); |