Skip to content

Commit 0391ece

Browse files
committed
feat: 회원가입 약관동의 팝업 구현
1 parent d559c4b commit 0391ece

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

src/tests/join.test.tsx

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { JoinPage } from '../pages';
44
import wrapper from './helpers/wrapper';
55
import supabase from '@/supabase';
66
import '@testing-library/jest-dom';
7+
import { BrowserRouter as Router } from 'react-router-dom';
78

89
vi.mock('@/supabase', () => ({
910
default: {
@@ -15,11 +16,17 @@ vi.mock('@/supabase', () => ({
1516

1617
describe('Join test', () => {
1718
beforeEach(() => {
18-
render(<JoinPage />, {
19-
wrapper,
20-
});
2119
window.HTMLDialogElement.prototype.showModal = vi.fn();
2220
window.HTMLDialogElement.prototype.close = vi.fn();
21+
22+
render(
23+
<Router>
24+
<JoinPage />
25+
</Router>,
26+
{
27+
wrapper,
28+
},
29+
);
2330
});
2431

2532
afterEach(() => {
@@ -107,17 +114,8 @@ describe('Join test', () => {
107114
it('이용약관 및 개인정보 관련 체크를 하지 않으면 에러 텍스트를 보여줄 수 있어야 한다.', async () => {
108115
const useTermsCheckInput = screen.getByLabelText(/useTermsCheck/i) as HTMLInputElement;
109116
const privacyTermsCheckInput = screen.getByLabelText(/privacyTermsCheck/i) as HTMLInputElement;
110-
111-
fireEvent.change(useTermsCheckInput, {
112-
target: {
113-
checked: false,
114-
},
115-
});
116-
fireEvent.change(privacyTermsCheckInput, {
117-
target: {
118-
checked: false,
119-
},
120-
});
117+
fireEvent.click(useTermsCheckInput);
118+
fireEvent.click(privacyTermsCheckInput);
121119
await waitFor(() => {});
122120
expect(screen.getByText(/ /)).toBeInTheDocument();
123121
expect(screen.getByText(/ , /)).toBeInTheDocument();
@@ -163,16 +161,15 @@ describe('Join test', () => {
163161
value: '111111',
164162
},
165163
});
166-
fireEvent.click(useTermsCheckInput, {
167-
target: {
168-
checked: true,
169-
},
170-
});
171-
fireEvent.click(privacyTermsCheckInput, {
172-
target: {
173-
checked: true,
174-
},
175-
});
164+
165+
fireEvent.click(useTermsCheckInput);
166+
const useTermsCheck = screen.getByText('동의하기') as HTMLButtonElement;
167+
fireEvent.click(useTermsCheck);
168+
169+
fireEvent.click(privacyTermsCheckInput);
170+
const privacyTermsCheck = screen.getByText('동의하기') as HTMLButtonElement;
171+
fireEvent.click(privacyTermsCheck);
172+
176173
await waitFor(() => {});
177174
const submitButton = screen.getByText('회원가입 하기') as HTMLButtonElement;
178175
fireEvent.click(submitButton);
@@ -220,16 +217,8 @@ describe('Join test', () => {
220217
value: '123456',
221218
},
222219
});
223-
fireEvent.click(useTermsCheckInput, {
224-
target: {
225-
checked: false,
226-
},
227-
});
228-
fireEvent.click(privacyTermsCheckInput, {
229-
target: {
230-
checked: false,
231-
},
232-
});
220+
fireEvent.click(useTermsCheckInput);
221+
fireEvent.click(privacyTermsCheckInput);
233222
await waitFor(() => {});
234223
const submitButton = screen.getByText('회원가입 하기') as HTMLButtonElement;
235224
fireEvent.click(submitButton);

0 commit comments

Comments
 (0)