feat: add call duration
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
dynamicTime,
|
||||
dateFormat,
|
||||
shortTimestamp,
|
||||
formatDuration,
|
||||
getDayDifferenceFromNow,
|
||||
hasOneDayPassed,
|
||||
} from 'shared/helpers/timeHelper';
|
||||
@@ -93,6 +94,24 @@ describe('#shortTimestamp', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#formatDuration', () => {
|
||||
it('returns empty string for invalid values', () => {
|
||||
expect(formatDuration(null)).toEqual('');
|
||||
expect(formatDuration(undefined)).toEqual('');
|
||||
expect(formatDuration(-1)).toEqual('');
|
||||
expect(formatDuration('abc')).toEqual('');
|
||||
});
|
||||
|
||||
it('formats short durations as mm:ss', () => {
|
||||
expect(formatDuration(0)).toEqual('00:00');
|
||||
expect(formatDuration(133)).toEqual('02:13');
|
||||
});
|
||||
|
||||
it('formats long durations as hh:mm:ss', () => {
|
||||
expect(formatDuration(3733)).toEqual('01:02:13');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getDayDifferenceFromNow', () => {
|
||||
it('returns 0 for timestamps from today', () => {
|
||||
// Mock current date: May 5, 2023
|
||||
|
||||
Reference in New Issue
Block a user