Skip to content

Commit

Permalink
add DatasetAlerts unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Oct 9, 2023
1 parent 548119f commit 5685673
Showing 1 changed file with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('DatasetAlerts', () => {
it('renders the correct number of alerts', () => {
cy.mount(<DatasetAlerts alerts={alerts} />)
cy.findByText('Unpublished Dataset Private URL').should('exist')
const alertElements = cy.findAllByRole('alert').should('have.length', alerts.length)
})

it('renders alerts with correct content', () => {
Expand All @@ -45,7 +44,6 @@ describe('DatasetAlerts', () => {
it('renders alerts with correct headings', () => {
cy.fixture('../../../public/locales/en/dataset.json').then((dataset) => {
cy.mount(<DatasetAlerts alerts={alerts} />)

alerts.forEach((alert) => {
const alertHeading = removeMarkup(dataset.alerts[alert.message].heading)

Check failure on line 48 in tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx

View workflow job for this annotation

GitHub Actions / lint

Unsafe argument of type `any` assigned to a parameter of type `string`
console.log(JSON.stringify(alertHeading))
Expand All @@ -54,22 +52,20 @@ describe('DatasetAlerts', () => {
})
})
it('renders dynamic text', () => {
cy.fixture('../../../public/locales/en/dataset.json').then((dataset) => {
const dynamicFields = {
requestedVersion: 4.0,
returnedVersion: 2.0
}
const notFoundAlert = new DatasetAlert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND,
dynamicFields
)
cy.mount(<DatasetAlerts alerts={[notFoundAlert]} />)
const dynamicFields = {
requestedVersion: 4.0,
returnedVersion: 2.0
}
const notFoundAlert = new DatasetAlert(
'warning',
DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND,
dynamicFields
)
cy.mount(<DatasetAlerts alerts={[notFoundAlert]} />)

alerts.forEach((alert) => {
cy.findAllByRole('alert').should('contain.text', dynamicFields.requestedVersion)
cy.findAllByRole('alert').should('contain.text', dynamicFields.returnedVersion)
})
alerts.forEach((alert) => {

Check warning on line 66 in tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx

View workflow job for this annotation

GitHub Actions / lint

'alert' is defined but never used. Allowed unused args must match /^_/u
cy.findAllByRole('alert').should('contain.text', dynamicFields.requestedVersion)
cy.findAllByRole('alert').should('contain.text', dynamicFields.returnedVersion)
})
})
})

0 comments on commit 5685673

Please sign in to comment.