-
Notifications
You must be signed in to change notification settings - Fork 592
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
1 parent
28cfe3b
commit e7fa628
Showing
4 changed files
with
166 additions
and
35 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
96 changes: 96 additions & 0 deletions
96
frontend/packages/knative-plugin/src/components/revisions/__tests__/RevisionRow.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,96 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import * as _ from 'lodash'; | ||
import { TableData } from '@console/internal/components/factory'; | ||
import { ResourceLink } from '@console/internal/components/utils'; | ||
import { K8sResourceConditionStatus } from '@console/internal/module/k8s'; | ||
import { revisionObj } from '@console/dev-console/src/components/topology/__tests__/topology-knative-test-data'; | ||
import RevisionRow from '../RevisionRow'; | ||
import { ConditionTypes } from '../../../types'; | ||
|
||
type RevisionRowProps = React.ComponentProps<typeof RevisionRow>; | ||
let revData: RevisionRowProps; | ||
describe('RoutesOverviewList', () => { | ||
beforeEach(() => { | ||
revData = { | ||
obj: revisionObj, | ||
index: 0, | ||
style: { | ||
height: 'auto', | ||
left: 0, | ||
position: 'absolute', | ||
top: 0, | ||
width: '100%', | ||
}, | ||
}; | ||
}); | ||
|
||
it('should show ResourceLink for associated service', () => { | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const serviceDataTable = wrapper.find(TableData).at(2); | ||
expect(wrapper.find(TableData)).toHaveLength(8); | ||
expect(serviceDataTable.find(ResourceLink)).toHaveLength(1); | ||
expect(serviceDataTable.find(ResourceLink).props().kind).toEqual( | ||
'serving.knative.dev~v1beta1~Service', | ||
); | ||
}); | ||
|
||
it('should not show ResourceLink for associated service if not found in labels', () => { | ||
revData.obj.metadata = { | ||
...revData.obj.metadata, | ||
...{ | ||
labels: { | ||
'serving.knative.dev/configuration': 'overlayimage', | ||
'serving.knative.dev/configurationGeneration': '2', | ||
}, | ||
}, | ||
}; | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const serviceDataTable = wrapper.find(TableData).at(2); | ||
expect(wrapper.find(TableData)).toHaveLength(8); | ||
expect(serviceDataTable.find(ResourceLink)).toHaveLength(0); | ||
}); | ||
|
||
it('should show appropriate conditions', () => { | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const conditionColData = wrapper.find(TableData).at(4); | ||
expect(conditionColData.props().children).toEqual('3 OK / 4'); | ||
}); | ||
|
||
it('should show "-" in case of no status', () => { | ||
revData = _.omit(revData, 'obj.status'); | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const conditionColData = wrapper.find(TableData).at(4); | ||
expect(conditionColData.props().children).toEqual('-'); | ||
}); | ||
|
||
it('should show appropriate ready status and reason for ready state', () => { | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const readyColData = wrapper.find(TableData).at(5); | ||
const reasonColData = wrapper.find(TableData).at(6); | ||
expect(readyColData.props().children).toEqual('True'); | ||
expect(reasonColData.props().children).toEqual('-'); | ||
}); | ||
|
||
it('should show appropriate ready status and reason for not ready state', () => { | ||
revData.obj.status = { | ||
...revData.obj.status, | ||
...{ | ||
conditions: [ | ||
{ | ||
lastTransitionTime: '2019-12-27T05:06:47Z', | ||
status: K8sResourceConditionStatus.False, | ||
type: ConditionTypes.Ready, | ||
message: 'Something went wrong.', | ||
reason: 'Something went wrong.', | ||
}, | ||
], | ||
}, | ||
}; | ||
const wrapper = shallow(<RevisionRow {...revData} />); | ||
const readyColData = wrapper.find(TableData).at(5); | ||
const reasonColData = wrapper.find(TableData).at(6); | ||
expect(readyColData.props().children).toEqual('False'); | ||
expect(reasonColData.props().children).toEqual('Something went wrong.'); | ||
}); | ||
}); |
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
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