|
| 1 | +import { CalendarChannelSyncStatus } from '@/accounts/types/CalendarChannel'; |
| 2 | +import { MessageChannelSyncStatus } from '@/accounts/types/MessageChannel'; |
| 3 | +import { SyncStatus } from '@/settings/accounts/constants/SyncStatus'; |
| 4 | +import { computeSyncStatus } from '../computeSyncStatus'; |
| 5 | + |
| 6 | +describe('computeSyncStatus', () => { |
| 7 | + test('should return FAILED when both sync statuses are FAILED', () => { |
| 8 | + expect( |
| 9 | + computeSyncStatus( |
| 10 | + MessageChannelSyncStatus.FAILED_UNKNOWN, |
| 11 | + CalendarChannelSyncStatus.FAILED_UNKNOWN, |
| 12 | + ), |
| 13 | + ).toEqual(SyncStatus.FAILED); |
| 14 | + }); |
| 15 | + |
| 16 | + test('should return FAILED when message channel sync status is FAILED_UNKNOWN', () => { |
| 17 | + expect( |
| 18 | + computeSyncStatus( |
| 19 | + MessageChannelSyncStatus.FAILED_UNKNOWN, |
| 20 | + CalendarChannelSyncStatus.ACTIVE, |
| 21 | + ), |
| 22 | + ).toEqual(SyncStatus.FAILED); |
| 23 | + }); |
| 24 | + |
| 25 | + test('should return FAILED when message channel sync status is FAILED_INSUFFICIENT_PERMISSIONS', () => { |
| 26 | + expect( |
| 27 | + computeSyncStatus( |
| 28 | + MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS, |
| 29 | + CalendarChannelSyncStatus.ACTIVE, |
| 30 | + ), |
| 31 | + ).toEqual(SyncStatus.FAILED); |
| 32 | + }); |
| 33 | + |
| 34 | + test('should return FAILED when calendar channel sync status is FAILED_UNKNOWN', () => { |
| 35 | + expect( |
| 36 | + computeSyncStatus( |
| 37 | + MessageChannelSyncStatus.ACTIVE, |
| 38 | + CalendarChannelSyncStatus.FAILED_UNKNOWN, |
| 39 | + ), |
| 40 | + ).toEqual(SyncStatus.FAILED); |
| 41 | + }); |
| 42 | + |
| 43 | + test('should return FAILED when calendar channel sync status is FAILED_INSUFFICIENT_PERMISSIONS', () => { |
| 44 | + expect( |
| 45 | + computeSyncStatus( |
| 46 | + MessageChannelSyncStatus.ACTIVE, |
| 47 | + CalendarChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS, |
| 48 | + ), |
| 49 | + ).toEqual(SyncStatus.FAILED); |
| 50 | + }); |
| 51 | + |
| 52 | + test('should return IMPORTING when message channel sync status is ONGOING', () => { |
| 53 | + expect( |
| 54 | + computeSyncStatus( |
| 55 | + MessageChannelSyncStatus.ONGOING, |
| 56 | + CalendarChannelSyncStatus.ACTIVE, |
| 57 | + ), |
| 58 | + ).toEqual(SyncStatus.IMPORTING); |
| 59 | + }); |
| 60 | + |
| 61 | + test('should return IMPORTING when calendar channel sync status is ONGOING', () => { |
| 62 | + expect( |
| 63 | + computeSyncStatus( |
| 64 | + MessageChannelSyncStatus.ACTIVE, |
| 65 | + CalendarChannelSyncStatus.ONGOING, |
| 66 | + ), |
| 67 | + ).toEqual(SyncStatus.IMPORTING); |
| 68 | + }); |
| 69 | + |
| 70 | + test('should return SYNCED when one channel is ACTIVE and the other is NOT_SYNCED', () => { |
| 71 | + expect( |
| 72 | + computeSyncStatus( |
| 73 | + MessageChannelSyncStatus.NOT_SYNCED, |
| 74 | + CalendarChannelSyncStatus.ACTIVE, |
| 75 | + ), |
| 76 | + ).toEqual(SyncStatus.SYNCED); |
| 77 | + }); |
| 78 | + |
| 79 | + test('should return SYNCED when one channel is ACTIVE and the other is NOT_SYNCED', () => { |
| 80 | + expect( |
| 81 | + computeSyncStatus( |
| 82 | + MessageChannelSyncStatus.ACTIVE, |
| 83 | + CalendarChannelSyncStatus.NOT_SYNCED, |
| 84 | + ), |
| 85 | + ).toEqual(SyncStatus.SYNCED); |
| 86 | + }); |
| 87 | +}); |
0 commit comments