-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test for new footer component
- Loading branch information
1 parent
fc9188c
commit 9f7b606
Showing
1 changed file
with
71 additions
and
0 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
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'); | ||
}); | ||
}); |