Skip to content

Commit

Permalink
add unit test for new footer component
Browse files Browse the repository at this point in the history
  • Loading branch information
raejohanek committed Nov 13, 2024
1 parent fc9188c commit 9f7b606
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions cypress/component/DataSearch/data_search_footer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* eslint-disable no-undef */
import {mount} from 'cypress/react';
import {React} from 'react';
import {DatasetSearchFooter} from '../../../src/components/data_search/DatasetSearchFooter';

const datasets = [
{
datasetId: 123456,
datasetIdentifier: `DUOS-123456`,
datasetName: 'Some Dataset 1',
study: {
studyId: 1,
}
},
{
datasetId: 234567,
datasetIdentifier: `DUOS-234567`,
datasetName: 'Some Dataset 2',
study: {
studyId: 1,
}
},
{
datasetId: 345678,
datasetIdentifier: `DUOS-345678`,
datasetName: 'Some Dataset 3',
study: {
studyId: 2,
}
},
];

const oneDatasetProps = {
selectedDatasets: [123456],
datasets: datasets,
onClick: () => {},
};

const oneStudyProps = {
selectedDatasets: [123456, 234567],
datasets: datasets,
onClick: () => {},
};

const twoStudiesProps = {
selectedDatasets: [123456, 234567, 345678],
datasets: datasets,
onClick: () => {},
};

describe('Dataset Search Footer renders correct text and button', () => {

it('Shows button and single dataset and study text', () => {
mount(<DatasetSearchFooter {...oneDatasetProps} />);
cy.contains('1 dataset selected from 1 study');
cy.contains('Apply for Access');
});


it('Shows button and two datasets from one study text', () => {
mount(<DatasetSearchFooter {...oneStudyProps} />);
cy.contains('2 datasets selected from 1 study');
cy.contains('Apply for Access');
});

it('Shows button and three datasets from two studies text', () => {
mount(<DatasetSearchFooter {...twoStudiesProps} />);
cy.contains('3 datasets selected from 2 studies');
cy.contains('Apply for Access');
});
});

0 comments on commit 9f7b606

Please sign in to comment.