Skip to content

Commit

Permalink
add test coverage for Dataset.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ekraffmiller committed Jul 10, 2024
1 parent 2ca38f3 commit d3aac21
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions tests/component/sections/dataset/Dataset.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FilesWithCount } from '../../../../src/files/domain/models/FilesWithCou
import { FilesCountInfoMother } from '../../files/domain/models/FilesCountInfoMother'
import { FileType } from '../../../../src/files/domain/models/FileMetadata'
import { FileAccessOption, FileTag } from '../../../../src/files/domain/models/FileCriteria'
import { AlertProvider } from '../../../../src/sections/alerts/AlertProvider'

const setAnonymizedView = () => {}
const fileRepository: FileRepository = {} as FileRepository
Expand Down Expand Up @@ -67,11 +68,13 @@ describe('Dataset', () => {

cy.customMount(
<LoadingProvider>
<AnonymizedContext.Provider value={{ anonymizedView: anonymizedView, setAnonymizedView }}>
<DatasetProvider repository={datasetRepository} searchParams={searchParams}>
{component}
</DatasetProvider>
</AnonymizedContext.Provider>
<AlertProvider>
<AnonymizedContext.Provider value={{ anonymizedView: anonymizedView, setAnonymizedView }}>
<DatasetProvider repository={datasetRepository} searchParams={searchParams}>
{component}
</DatasetProvider>
</AnonymizedContext.Provider>
</AlertProvider>
</LoadingProvider>
)
}
Expand All @@ -98,6 +101,35 @@ describe('Dataset', () => {

cy.findByText('Page Not Found').should('exist')
})
it('renders Success alert when dataset is created', () => {
const dataset = DatasetMother.create()

mountWithDataset(
<Dataset
created={true}
datasetRepository={datasetRepository}
fileRepository={fileRepository}
/>,
dataset
)

cy.findByText('Success!').should('exist')
})
it('renders In Progress alert when dataset publish is inProgress', () => {
const dataset = DatasetMother.create()

mountWithDataset(
<Dataset
created={false}
publishInProgress={true}
datasetRepository={datasetRepository}
fileRepository={fileRepository}
/>,
dataset
)

cy.findByText('Publish in Progress').should('exist')
})

it('renders the breadcrumbs', () => {
const testDataset = DatasetMother.create()
Expand Down

0 comments on commit d3aac21

Please sign in to comment.