|
| 1 | +import {ArrowsRotateLeft, ArrowsRotateLeftSlash} from '@gravity-ui/icons'; |
| 2 | + |
1 | 3 | import type {EVDiskDetailedReplicationStatus} from '../../types/api/vdisk'; |
2 | 4 | import {EVDiskState} from '../../types/api/vdisk'; |
3 | 5 |
|
@@ -31,8 +33,39 @@ describe('VDisk replication label', () => { |
31 | 33 | }); |
32 | 34 |
|
33 | 35 | test('uses the boolean fallback only when the detailed status is absent', () => { |
34 | | - expect(getVDiskReplicationLabel({Replicated: false})?.value).toBe('Not replicated'); |
| 36 | + expect(getVDiskReplicationLabel({Replicated: false})).toMatchObject({ |
| 37 | + value: 'Not replicated', |
| 38 | + theme: 'normal', |
| 39 | + icon: ArrowsRotateLeftSlash, |
| 40 | + }); |
35 | 41 | expect(getVDiskReplicationLabel({Replicated: true})?.value).toBe('Replicated'); |
36 | 42 | expect(getVDiskReplicationLabel({})).toBeUndefined(); |
37 | 43 | }); |
| 44 | + |
| 45 | + test.each([ |
| 46 | + {ReplicationProgress: 0}, |
| 47 | + {ReplicationProgress: 0.77}, |
| 48 | + {ReplicationProgress: 1}, |
| 49 | + {ReplicationSecondsRemaining: 0}, |
| 50 | + {ReplicationSecondsRemaining: 125}, |
| 51 | + ])('shows No detailed status with available replication metrics %p', (metrics) => { |
| 52 | + expect(getVDiskReplicationLabel({Replicated: false, ...metrics})).toMatchObject({ |
| 53 | + title: 'Replication', |
| 54 | + value: 'No detailed status', |
| 55 | + theme: 'info', |
| 56 | + icon: ArrowsRotateLeft, |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + test.each([ |
| 61 | + {ReplicationProgress: -0.1}, |
| 62 | + {ReplicationProgress: 1.1}, |
| 63 | + {ReplicationProgress: NaN}, |
| 64 | + {ReplicationSecondsRemaining: -1}, |
| 65 | + {ReplicationSecondsRemaining: Infinity}, |
| 66 | + ])('keeps Not replicated when replication metrics are invalid %p', (metrics) => { |
| 67 | + expect(getVDiskReplicationLabel({Replicated: false, ...metrics})?.value).toBe( |
| 68 | + 'Not replicated', |
| 69 | + ); |
| 70 | + }); |
38 | 71 | }); |
0 commit comments