Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
karthik
committed
Dec 17, 2020
1 parent
f9339b9
commit d1660b2
Showing
3 changed files
with
59 additions
and
5 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
47 changes: 47 additions & 0 deletions
47
...s-plugin/src/components/pipelines/list-page/__tests__/PipelineAugmentRunsWrapper.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,47 @@ | ||
import * as React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { LoadingBox } from '@console/internal/components/utils'; | ||
import { ListPageWrapper_ as ListPageWrapper } from '@console/internal/components/factory'; | ||
import { PipelineExampleNames, pipelineTestData } from '../../../../test-data/pipeline-data'; | ||
import PipelineAugmentRunsWrapper from '../PipelineAugmentRunsWrapper'; | ||
|
||
const mockData = pipelineTestData[PipelineExampleNames.WORKSPACE_PIPELINE]; | ||
const { pipeline } = mockData; | ||
|
||
type PipelineAugmentRunsWrapperProps = React.ComponentProps<typeof PipelineAugmentRunsWrapper>; | ||
|
||
jest.mock('react-i18next', () => { | ||
const reactI18next = require.requireActual('react-i18next'); | ||
return { | ||
...reactI18next, | ||
useTranslation: () => ({ t: (key) => key }), | ||
}; | ||
}); | ||
|
||
describe('Pipeline Augment Run Wrapper', () => { | ||
let pipelineAugmentRunsWrapperProps: PipelineAugmentRunsWrapperProps; | ||
let wrapper: ShallowWrapper; | ||
beforeEach(() => { | ||
pipelineAugmentRunsWrapperProps = { | ||
pipeline: { | ||
data: [pipeline], | ||
loaded: false, | ||
}, | ||
}; | ||
wrapper = shallow(<PipelineAugmentRunsWrapper {...pipelineAugmentRunsWrapperProps} />); | ||
}); | ||
|
||
it('Should not render if the firehose call is not yet loaded', () => { | ||
expect(wrapper.find(LoadingBox).exists()).toBeTruthy(); | ||
}); | ||
|
||
it('Should not render the listPageWrapper if the data is empty', () => { | ||
wrapper.setProps({ pipeline: { data: [], loaded: true } }); | ||
expect(wrapper.find(ListPageWrapper).exists()).toBeFalsy(); | ||
}); | ||
|
||
it('Should render firehose if the pipeline data is loaded and available', () => { | ||
wrapper.setProps({ pipeline: { data: [pipeline], loaded: true } }); | ||
expect(wrapper.find(ListPageWrapper).exists()).toBeTruthy(); | ||
}); | ||
}); |
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