Skip to content

Commit

Permalink
fix: change target grade-upload test
Browse files Browse the repository at this point in the history
  • Loading branch information
yougyung committed Mar 16, 2024
1 parent f05c75e commit c54c917
Showing 1 changed file with 16 additions and 4 deletions.
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();
});
});

0 comments on commit c54c917

Please sign in to comment.