-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: snyk-bot <[email protected]> Co-authored-by: ericboucher <[email protected]> Co-authored-by: Eric Boucher <[email protected]>
- Loading branch information
1 parent
17afb83
commit 7a6ad93
Showing
54 changed files
with
2,067 additions
and
96 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
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
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
71 changes: 71 additions & 0 deletions
71
packages/website/src/common/SiteDetails/Surveys/ReefCheckSurveyCard/index.test.tsx
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { mockReefCheckSurvey } from 'mocks/mockReefCheckSurvey'; | ||
import { ReefCheckSurvey } from 'store/ReefCheckSurveys'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import { ThemeProvider } from '@mui/material'; | ||
import theme from 'layout/App/theme'; | ||
import { ReefCheckSurveyCard } from '.'; | ||
|
||
describe('ReefCheckSurveyCard', () => { | ||
function renderReefCheckSurveyCard(overrides: Partial<ReefCheckSurvey> = {}) { | ||
return render( | ||
<ThemeProvider theme={theme}> | ||
<BrowserRouter> | ||
<ReefCheckSurveyCard | ||
survey={{ ...mockReefCheckSurvey, ...overrides }} | ||
/> | ||
</BrowserRouter> | ||
</ThemeProvider>, | ||
); | ||
} | ||
|
||
it('should render date', () => { | ||
const { getByText } = renderReefCheckSurveyCard(); | ||
|
||
expect( | ||
getByText(`Date: ${new Date(mockReefCheckSurvey.date).toLocaleString()}`), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render user if submittedBy is present', () => { | ||
const { getByText } = renderReefCheckSurveyCard({ | ||
submittedBy: 'Test User', | ||
}); | ||
expect(getByText('User: Test User')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render table with correct number of rows', () => { | ||
const { container } = renderReefCheckSurveyCard(); | ||
|
||
expect(container.querySelectorAll('mock-tablerow').length).toBe(3); | ||
}); | ||
|
||
it('should show correct counts in headers', () => { | ||
const { container } = renderReefCheckSurveyCard(); | ||
const headers = [ | ||
...container.querySelectorAll('mock-tablehead mock-tablecell').values(), | ||
].map((el) => el.textContent); | ||
expect(headers).toEqual( | ||
expect.arrayContaining([ | ||
'FISH (2)', | ||
'Count', | ||
'INVERTEBRATES (2)', | ||
'Count', | ||
'BLEACHING AND CORAL DIDEASES', | ||
'YES/NO', | ||
'IMPACT', | ||
'YES/NO', | ||
]), | ||
); | ||
}); | ||
|
||
it('should display link to survey details', () => { | ||
const { getByRole } = renderReefCheckSurveyCard(); | ||
|
||
expect(getByRole('link', { name: 'VIEW DETAILS' })).toHaveAttribute( | ||
'href', | ||
`/reef_check_survey/${mockReefCheckSurvey.id}`, | ||
); | ||
}); | ||
}); |
Oops, something went wrong.