From 5685673cd02f2170546d6e66334400907c57457c Mon Sep 17 00:00:00 2001 From: Ellen Kraffmiller Date: Mon, 9 Oct 2023 15:38:19 -0400 Subject: [PATCH] add DatasetAlerts unit test --- .../dataset-alerts/DatasetAlerts.spec.tsx | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx b/tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx index 4bc468499..4dc43c559 100644 --- a/tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx +++ b/tests/component/sections/dataset/dataset-alerts/DatasetAlerts.spec.tsx @@ -26,7 +26,6 @@ describe('DatasetAlerts', () => { it('renders the correct number of alerts', () => { cy.mount() cy.findByText('Unpublished Dataset Private URL').should('exist') - const alertElements = cy.findAllByRole('alert').should('have.length', alerts.length) }) it('renders alerts with correct content', () => { @@ -45,7 +44,6 @@ describe('DatasetAlerts', () => { it('renders alerts with correct headings', () => { cy.fixture('../../../public/locales/en/dataset.json').then((dataset) => { cy.mount() - alerts.forEach((alert) => { const alertHeading = removeMarkup(dataset.alerts[alert.message].heading) console.log(JSON.stringify(alertHeading)) @@ -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() + const dynamicFields = { + requestedVersion: 4.0, + returnedVersion: 2.0 + } + const notFoundAlert = new DatasetAlert( + 'warning', + DatasetAlertMessageKey.REQUESTED_VERSION_NOT_FOUND, + dynamicFields + ) + cy.mount() - alerts.forEach((alert) => { - cy.findAllByRole('alert').should('contain.text', dynamicFields.requestedVersion) - cy.findAllByRole('alert').should('contain.text', dynamicFields.returnedVersion) - }) + alerts.forEach((alert) => { + cy.findAllByRole('alert').should('contain.text', dynamicFields.requestedVersion) + cy.findAllByRole('alert').should('contain.text', dynamicFields.returnedVersion) }) }) })