Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grade upload/#9 #41

Merged
merged 18 commits into from
Mar 18, 2024
Merged
Changes from 1 commit
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
20 changes: 16 additions & 4 deletions app/__test__/ui/view/upload-pdf.test.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import UploadPdf from '@/app/ui/view/molecule/upload-pdf/upload-pdf';
import { render, screen } from '@testing-library/react';
import fireEvent from '@testing-library/user-event';
import { userEvent } from '@testing-library/user-event';

describe('์„ฑ์  ์—…๋กœ๋“œ', () => {
it('pdf๊ฐ€ ์•„๋‹Œ ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•  ์ˆ˜ ์—†๋‹ค', async () => {
it('ํŒŒ์ผ์ด ์—…๋กœ๋“œ ๋  ๋•Œ, pdf file์„ ์—…๋กœ๋“œ ํ•˜๋ฉด file๋ช…์ด ๋…ธ์ถœ๋œ๋‹ค.', async () => {
render(<UploadPdf />);

const targetFile = new File(['grade'], 'grade.pdf', {
type: 'text/plain',
});

const uploadBox = await screen.findByTestId('upload-box');
fireEvent.upload(uploadBox, targetFile);
await userEvent.upload(uploadBox, targetFile);

expect(screen.queryByText('์ถ”๊ฐ€')).not.toBeInTheDocument();
expect(screen.getByText(targetFile.name)).toBeInTheDocument();
});

it('ํŒŒ์ผ์ด ์—…๋กœ๋“œ ๋  ๋•Œ, pdf๊ฐ€ ์•„๋‹Œ file์„ ์—…๋กœ๋“œ ํ•˜๋ฉด ๋ณ€ํ™”๊ฐ€ ๋ฐœ์ƒํ•˜์ง€์•Š๋Š”๋‹ค.', async () => {
render(<UploadPdf />);

const targetFile = new File(['grade'], 'grade.png', {
type: 'text/plain',
});

const uploadBox = await screen.findByTestId('upload-box');
await userEvent.upload(uploadBox, targetFile);
expect(screen.queryByText('๋งˆ์šฐ์Šค๋กœ ๋“œ๋ž˜๊ทธ ํ•˜๊ฑฐ๋‚˜ ์•„์ด์ฝ˜์„ ๋ˆŒ๋Ÿฌ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.')).toBeInTheDocument();
Comment on lines +16 to +28
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getByText๋ž‘ queryByText ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ์ค€์„ ์—ฌ์ญค๋ด๋„ ๋ ๊นŒ์š”!?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐœ๋ฐœ๊ณผ์ •์—์„œ ๋กœ์ง์„ ์œ„ํ•ด ๋ฉ”์†Œ๋“œ๋ฅผ ๋‹ค๋ฅด๊ฒŒ ๊ฐ€์ ธ๊ฐ”๋Š”๋ฐ, ๋ณ€๊ฒฝ์ด ๋ฐœ์ƒํ•˜๋ฉด์„œ ํ˜„์žฌ๋Š” ์–ด๋–ค ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด๋„ ์ ์šฉ์ด ๋˜๋Š” ์ƒํ™ฉ์ž…๋‹ˆ๋‹ค!

});
});
Loading