forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#7547 from karthikjeeyar/pipeline-list-lo…
…ader Bug 1907888: Fix pipeline list page loader
- Loading branch information
Showing
2 changed files
with
57 additions
and
8 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 { EmptyBox, 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 render loader if data not yet loaded', () => { | ||
expect(wrapper.find(LoadingBox).exists()).toBeTruthy(); | ||
}); | ||
|
||
it('Should render the EmptyBox if the data is empty', () => { | ||
wrapper.setProps({ pipeline: { data: [], loaded: true } }); | ||
expect(wrapper.find(EmptyBox).exists()).toBeTruthy(); | ||
}); | ||
|
||
it('Should render ListpageWrapper if the pipeline data is loaded and available', () => { | ||
wrapper.setProps({ pipeline: { data: [pipeline], loaded: true } }); | ||
expect(wrapper.find(ListPageWrapper).exists()).toBeTruthy(); | ||
}); | ||
}); |