|
| 1 | +import { |
| 2 | + CallDirection, |
| 3 | + CallEvent, |
| 4 | + CallParticipantType, |
| 5 | + CallState, |
| 6 | +} from '../models'; |
| 7 | +import { getTextDescriptionForCallevent } from './callEventHelper'; |
| 8 | + |
| 9 | +const generateBaseCallEvent = (): CallEvent => ({ |
| 10 | + id: 'callEventId123', |
| 11 | + startTime: 1705832625000, |
| 12 | + endTime: 1705833276000, |
| 13 | + direction: CallDirection.IN, |
| 14 | + participants: [ |
| 15 | + { |
| 16 | + type: CallParticipantType.LOCAL, |
| 17 | + phoneNumber: '4921177722233', |
| 18 | + }, |
| 19 | + { |
| 20 | + type: CallParticipantType.REMOTE, |
| 21 | + phoneNumber: '4922199911122', |
| 22 | + }, |
| 23 | + ], |
| 24 | + note: 'testnote01', |
| 25 | + state: CallState.CONNECTED, |
| 26 | +}); |
| 27 | + |
| 28 | +describe('callEventHelper', () => { |
| 29 | + describe('getTextDescriptionForCallevent for german locale', () => { |
| 30 | + it('should generate sane description for incoming, connected callEvent', () => { |
| 31 | + const callEvent = generateBaseCallEvent(); |
| 32 | + |
| 33 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 34 | + 'Angenommener eingehender Anruf von 4922199911122 auf 4921177722233 am 21.1.2024, 11:23:45 Uhr, Dauer: 10:51 Minuten.', |
| 35 | + ); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should generate sane description for outgoing, connected callEvent', () => { |
| 39 | + const callEvent = generateBaseCallEvent(); |
| 40 | + callEvent.direction = CallDirection.OUT; |
| 41 | + |
| 42 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 43 | + 'Angenommener ausgehender Anruf von 4921177722233 auf 4922199911122 am 21.1.2024, 11:23:45 Uhr, Dauer: 10:51 Minuten.', |
| 44 | + ); |
| 45 | + }); |
| 46 | + |
| 47 | + it('should generate sane description for incoming, missed callEvent', () => { |
| 48 | + const callEvent = generateBaseCallEvent(); |
| 49 | + callEvent.state = CallState.MISSED; |
| 50 | + |
| 51 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 52 | + 'Nicht angenommener eingehender Anruf von 4922199911122 auf 4921177722233 am 21.1.2024, 11:23:45 Uhr.', |
| 53 | + ); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should generate sane description for outgoing, missed callEvent', () => { |
| 57 | + const callEvent = generateBaseCallEvent(); |
| 58 | + callEvent.direction = CallDirection.OUT; |
| 59 | + callEvent.state = CallState.MISSED; |
| 60 | + |
| 61 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 62 | + 'Nicht angenommener ausgehender Anruf von 4921177722233 auf 4922199911122 am 21.1.2024, 11:23:45 Uhr.', |
| 63 | + ); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should generate sane description for incoming, busy callEvent', () => { |
| 67 | + const callEvent = generateBaseCallEvent(); |
| 68 | + callEvent.state = CallState.BUSY; |
| 69 | + |
| 70 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 71 | + 'Nicht angenommener eingehender Anruf von 4922199911122 auf 4921177722233 am 21.1.2024, 11:23:45 Uhr.', |
| 72 | + ); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should generate sane description for outgoing, busy callEvent', () => { |
| 76 | + const callEvent = generateBaseCallEvent(); |
| 77 | + callEvent.direction = CallDirection.OUT; |
| 78 | + callEvent.state = CallState.BUSY; |
| 79 | + |
| 80 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 81 | + 'Nicht angenommener ausgehender Anruf von 4921177722233 auf 4922199911122 am 21.1.2024, 11:23:45 Uhr.', |
| 82 | + ); |
| 83 | + }); |
| 84 | + |
| 85 | + it('should generate sane description for incoming, not_found callEvent', () => { |
| 86 | + const callEvent = generateBaseCallEvent(); |
| 87 | + callEvent.state = CallState.NOT_FOUND; |
| 88 | + |
| 89 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 90 | + 'Nicht angenommener eingehender Anruf von 4922199911122 auf 4921177722233 am 21.1.2024, 11:23:45 Uhr.', |
| 91 | + ); |
| 92 | + }); |
| 93 | + |
| 94 | + it('should generate sane description for outgoing, not_found callEvent', () => { |
| 95 | + const callEvent = generateBaseCallEvent(); |
| 96 | + callEvent.direction = CallDirection.OUT; |
| 97 | + callEvent.state = CallState.NOT_FOUND; |
| 98 | + |
| 99 | + expect(getTextDescriptionForCallevent(callEvent)).toEqual( |
| 100 | + 'Nicht angenommener ausgehender Anruf von 4921177722233 auf 4922199911122 am 21.1.2024, 11:23:45 Uhr.', |
| 101 | + ); |
| 102 | + }); |
| 103 | + }); |
| 104 | + |
| 105 | + describe('getTextDescriptionForCallevent for english locale', () => { |
| 106 | + it('should generate sane description for incoming, connected callEvent', () => { |
| 107 | + const callEvent = generateBaseCallEvent(); |
| 108 | + |
| 109 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 110 | + 'Answered incoming call from 4922199911122 to 4921177722233 on 1/21/2024, 11:23:45 AM, duration: 10:51 minutes.', |
| 111 | + ); |
| 112 | + }); |
| 113 | + |
| 114 | + it('should generate sane description for outgoing, connected callEvent', () => { |
| 115 | + const callEvent = generateBaseCallEvent(); |
| 116 | + callEvent.direction = CallDirection.OUT; |
| 117 | + |
| 118 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 119 | + 'Answered outgoing call from 4921177722233 to 4922199911122 on 1/21/2024, 11:23:45 AM, duration: 10:51 minutes.', |
| 120 | + ); |
| 121 | + }); |
| 122 | + |
| 123 | + it('should generate sane description for incoming, missed callEvent', () => { |
| 124 | + const callEvent = generateBaseCallEvent(); |
| 125 | + callEvent.state = CallState.MISSED; |
| 126 | + |
| 127 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 128 | + 'Unanswered incoming call from 4922199911122 to 4921177722233 on 1/21/2024, 11:23:45 AM.', |
| 129 | + ); |
| 130 | + }); |
| 131 | + |
| 132 | + it('should generate sane description for outgoing, missed callEvent', () => { |
| 133 | + const callEvent = generateBaseCallEvent(); |
| 134 | + callEvent.direction = CallDirection.OUT; |
| 135 | + callEvent.state = CallState.MISSED; |
| 136 | + |
| 137 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 138 | + 'Unanswered outgoing call from 4921177722233 to 4922199911122 on 1/21/2024, 11:23:45 AM.', |
| 139 | + ); |
| 140 | + }); |
| 141 | + |
| 142 | + it('should generate sane description for incoming, busy callEvent', () => { |
| 143 | + const callEvent = generateBaseCallEvent(); |
| 144 | + callEvent.state = CallState.BUSY; |
| 145 | + |
| 146 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 147 | + 'Unanswered incoming call from 4922199911122 to 4921177722233 on 1/21/2024, 11:23:45 AM.', |
| 148 | + ); |
| 149 | + }); |
| 150 | + |
| 151 | + it('should generate sane description for outgoing, busy callEvent', () => { |
| 152 | + const callEvent = generateBaseCallEvent(); |
| 153 | + callEvent.direction = CallDirection.OUT; |
| 154 | + callEvent.state = CallState.BUSY; |
| 155 | + |
| 156 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 157 | + 'Unanswered outgoing call from 4921177722233 to 4922199911122 on 1/21/2024, 11:23:45 AM.', |
| 158 | + ); |
| 159 | + }); |
| 160 | + |
| 161 | + it('should generate sane description for incoming, not_found callEvent', () => { |
| 162 | + const callEvent = generateBaseCallEvent(); |
| 163 | + callEvent.state = CallState.NOT_FOUND; |
| 164 | + |
| 165 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 166 | + 'Unanswered incoming call from 4922199911122 to 4921177722233 on 1/21/2024, 11:23:45 AM.', |
| 167 | + ); |
| 168 | + }); |
| 169 | + |
| 170 | + it('should generate sane description for outgoing, not_found callEvent', () => { |
| 171 | + const callEvent = generateBaseCallEvent(); |
| 172 | + callEvent.direction = CallDirection.OUT; |
| 173 | + callEvent.state = CallState.NOT_FOUND; |
| 174 | + |
| 175 | + expect(getTextDescriptionForCallevent(callEvent, 'en-US')).toEqual( |
| 176 | + 'Unanswered outgoing call from 4921177722233 to 4922199911122 on 1/21/2024, 11:23:45 AM.', |
| 177 | + ); |
| 178 | + }); |
| 179 | + }); |
| 180 | +}); |
0 commit comments