-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
3 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
37 changes: 35 additions & 2 deletions
37
...nit/containers/my-cooperations/accept-cooperation-close/AcceptCooperationClosing.spec.jsx
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 |
---|---|---|
@@ -1,15 +1,48 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { fireEvent, render, screen } from '@testing-library/react' | ||
import { beforeEach, vi } from 'vitest' | ||
import AcceptCooperationClosing from '~/containers/my-cooperations/accept-cooperation-close/AcceptCooperationClosing' | ||
|
||
vi.mock('react-i18next', () => ({ | ||
useTranslation: () => ({ | ||
t: (key) => key | ||
}) | ||
})) | ||
describe('AcceptCooperationClosing', () => { | ||
const mockOnAccept = vi.fn() | ||
const mockOnDecline = vi.fn() | ||
|
||
beforeEach(() => { | ||
render(<AcceptCooperationClosing user='John Doe' onAccept={mockOnAccept} />) | ||
render( | ||
<AcceptCooperationClosing | ||
user='John Doe' | ||
onAccept={mockOnAccept} | ||
onDecline={mockOnDecline} | ||
/> | ||
) | ||
}) | ||
|
||
it('should render the title correctly', () => { | ||
const titleText = screen.getByText('titles.acceptCooperationClosing') | ||
expect(titleText).toBeInTheDocument() | ||
}) | ||
|
||
it('renders input field when decline button is clicked', () => { | ||
const declineBtn = screen.getByText('cooperationDetailsPage.declineBtn') | ||
fireEvent.click(declineBtn) | ||
expect(declineBtn).toBeInTheDocument() | ||
const inputLabel = screen.getByText( | ||
'cooperationDetailsPage.InputFieldLabel' | ||
) | ||
expect(inputLabel).toBeInTheDocument() | ||
}) | ||
|
||
it('shows error message when submitting empty input', () => { | ||
const declineBtn = screen.getByText('cooperationDetailsPage.declineBtn') | ||
fireEvent.click(declineBtn) | ||
const submitBtn = screen.getByText('cooperationDetailsPage.submitBtn') | ||
expect(submitBtn).toBeInTheDocument() | ||
fireEvent.click(submitBtn) | ||
const errorMessage = screen.getByText('cooperationDetailsPage.inputError') | ||
expect(errorMessage).toBeInTheDocument() | ||
}) | ||
}) |