-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for upload dataset files page
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.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,49 @@ | ||
import { DatasetRepository } from '../../../../src/dataset/domain/repositories/DatasetRepository' | ||
import { DatasetMother } from '../../dataset/domain/models/DatasetMother' | ||
import { FileRepository } from '../../../../src/files/domain/repositories/FileRepository' | ||
import { Dataset as DatasetModel } from '../../../../src/dataset/domain/models/Dataset' | ||
import { ReactNode } from 'react' | ||
import { DatasetProvider } from '../../../../src/sections/dataset/DatasetProvider' | ||
import { UploadDatasetFiles } from '../../../../src/sections/upload-dataset-files/UploadDatasetFiles' | ||
|
||
const fileRepository: FileRepository = {} as FileRepository | ||
const datasetRepository: DatasetRepository = {} as DatasetRepository | ||
|
||
describe('Dataset', () => { | ||
const mountWithDataset = (component: ReactNode, dataset: DatasetModel | undefined) => { | ||
const searchParams = { persistentId: 'some-persistent-id' } | ||
datasetRepository.getByPersistentId = cy.stub().resolves(dataset) | ||
|
||
cy.customMount( | ||
<DatasetProvider repository={datasetRepository} searchParams={searchParams}> | ||
{component} | ||
</DatasetProvider> | ||
) | ||
} | ||
|
||
it('renders skeleton while loading', () => { | ||
const testDataset = DatasetMother.create() | ||
|
||
mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset) | ||
|
||
cy.findByText('Temporary Loading until having shape of skeleton').should('exist') | ||
cy.findByText(testDataset.version.title).should('not.exist') | ||
}) | ||
|
||
it('renders page not found when dataset is null', () => { | ||
const emptyDataset = DatasetMother.createEmpty() | ||
|
||
mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, emptyDataset) | ||
|
||
cy.findByText('Page Not Found').should('exist') | ||
}) | ||
|
||
it('renders the breadcrumbs', () => { | ||
const testDataset = DatasetMother.create() | ||
|
||
mountWithDataset(<UploadDatasetFiles fileRepository={fileRepository} />, testDataset) | ||
|
||
cy.findByText('Dataset Title').should('exist').should('have.class', 'active') | ||
cy.findByRole('link', { name: 'Root' }).should('exist') | ||
}) | ||
}) |