Skip to content

Commit

Permalink
test: remove beforeEach
Browse files Browse the repository at this point in the history
  • Loading branch information
soomin9106 committed Jun 17, 2024
1 parent 2619c12 commit 2dfaea3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/workbook/components/SubscribeForm/SubscribeForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useForm } from 'react-hook-form';

import { beforeEach, describe, expect, it, vi } from 'vitest';
import { describe, expect, it, vi } from 'vitest';

import SubscribeForm from '.';
import { render, screen, waitFor } from '@testing-library/react';
Expand All @@ -17,11 +17,10 @@ vi.mock('@main/hooks/useSubscribeForm', () => ({
}));

describe('SubscribeForm 컴포넌트 동작 테스트', () => {
beforeEach(() => {
render(<SubscribeForm setIsOpen={mockSetIsOpen} />);
});

it('폼과 필드들을 올바르게 렌더링 한다.', () => {
render(<SubscribeForm setIsOpen={mockSetIsOpen} />);

expect(screen.getByPlaceholderText('이메일을 입력해주세요')).toBeInTheDocument();
expect(screen.getByText('개인정보 수집')).toBeInTheDocument();
expect(screen.getByText('광고성 정보 수신')).toBeInTheDocument();
Expand All @@ -30,6 +29,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => {
});

it('올바르지 않은 이메일 형식을 검사한다.', async () => {
render(<SubscribeForm setIsOpen={mockSetIsOpen} />);

const user = userEvent.setup();
const emailInput = screen.getByPlaceholderText('이메일을 입력해주세요');
const submitButton = screen.getByText('구독할게요');
Expand All @@ -50,6 +51,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => {
});

it('유효한 이메일을 폼에 제출한다.', async () => {
render(<SubscribeForm setIsOpen={mockSetIsOpen} />);

const user = userEvent.setup();
const emailInput = screen.getByPlaceholderText('이메일을 입력해주세요');
const submitButton = screen.getByText('구독할게요');
Expand All @@ -61,6 +64,8 @@ describe('SubscribeForm 컴포넌트 동작 테스트', () => {
});

it('좀 더 둘러볼래요 버튼 클릭 시 폼을 닫는다.', async () => {
render(<SubscribeForm setIsOpen={mockSetIsOpen} />);

const user = userEvent.setup();
const rejectButton = screen.getByText('좀 더 둘러볼래요');
await user.click(rejectButton);
Expand Down

0 comments on commit 2dfaea3

Please sign in to comment.