-
Notifications
You must be signed in to change notification settings - Fork 593
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
Showing
4 changed files
with
69 additions
and
6 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
52 changes: 52 additions & 0 deletions
52
frontend/packages/console-shared/src/utils/__tests__/pod-ring-utils.spec.ts
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,52 @@ | ||
import * as _ from 'lodash'; | ||
import { mockPod } from '../__mocks__/pod-utils-test-data'; | ||
import { podRingLabel } from '../pod-ring-utils'; | ||
import { ExtPodKind } from '../../types'; | ||
|
||
describe('pod-ring utils:', () => { | ||
it('should return proper title, subtitle for podRingLabel', () => { | ||
const podWithReplicas = _.set(mockPod, 'spec.replicas', 2); | ||
const mockData = _.set(podWithReplicas, 'status.availableReplicas', 2); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).title).toEqual(2); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitle).toEqual('pods'); | ||
}); | ||
|
||
it('should return title 0, subtitle scaling to 2 and no titleComponent, subtitleComponent for podRingLabel when scaling from 1 to 2 pods', () => { | ||
const podWithReplicas = _.set(_.cloneDeep(mockPod), 'spec.replicas', 2); | ||
const mockData = _.set(podWithReplicas, 'status.availableReplicas', 1); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).title).toEqual(1); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitle).toEqual('scaling to 2'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).titleComponent).toEqual( | ||
undefined, | ||
); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitleComponent).toEqual( | ||
undefined, | ||
); | ||
}); | ||
|
||
it('should return title 0, subtitle scaling to 1 and no titleComponent, subtitleComponent for podRingLabel when the first pod is being created', () => { | ||
const podWithReplicas = _.set(mockPod, 'spec.replicas', 1); | ||
const mockData = _.set(podWithReplicas, 'status.availableReplicas', 0); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).title).toEqual('0'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitle).toEqual('scaling to 1'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).titleComponent).toEqual( | ||
undefined, | ||
); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitleComponent).toEqual( | ||
undefined, | ||
); | ||
}); | ||
|
||
it('should return title 0, subtitle scaling to 1 and no titleComponent, subtitleComponent for podRingLabel when pod count is 1 and status is pending', () => { | ||
const podWithReplicas = _.set(_.cloneDeep(mockPod), 'spec.replicas', 1); | ||
const mockData = _.set(podWithReplicas, 'status.phase', 'Pending'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).title).toEqual('0'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitle).toEqual('scaling to 1'); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).titleComponent).toEqual( | ||
undefined, | ||
); | ||
expect(podRingLabel(mockData, true, [mockData as ExtPodKind]).subTitleComponent).toEqual( | ||
undefined, | ||
); | ||
}); | ||
}); |
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