Skip to content

Commit

Permalink
add one more test for CooperationCompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
nebby2105 committed Nov 28, 2024
1 parent e887657 commit 5012c83
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const CooperationCompletion: React.FC<CooperationCompletionProps> = ({
title={t('cooperationsPage.cooperationDetails.closeCooperationTitle')}
>
<AppButton
data-testid='close-cooperation-btn'
onClick={onCloseCooperation}
size={SizeEnum.Medium}
sx={styles.closeBtn}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { screen, render } from '@testing-library/react'
import { vi } from 'vitest'
import { screen, render, fireEvent, waitFor } from '@testing-library/react'
import { expect, vi } from 'vitest'
import CooperationCompletion from '~/containers/my-cooperations/cooperation-completion/CooperationCompletion'
import { UserRoleEnum } from '~/types'

Expand All @@ -21,5 +21,25 @@ describe('CooperationCompletion Component', () => {

const appSelect = screen.getByRole('combobox')
expect(appSelect).toBeInTheDocument()

const closeButton = screen.getByTestId('close-cooperation-btn')
expect(closeButton).toBeInTheDocument()
})

it('should call mockCloseCooperation when closing cooperation', async () => {
render(
<CooperationCompletion
onCloseCooperation={mockOnCloseCooperation}
userRole={UserRoleEnum.Tutor}
/>
)

const closeButton = screen.getByTestId('close-cooperation-btn')

fireEvent.click(closeButton)

await waitFor(() => {
expect(mockOnCloseCooperation).toHaveBeenCalled()
})
})
})

0 comments on commit 5012c83

Please sign in to comment.