Datetime: Added more tests to the files in the datetime folder (#71731)
* Datetime: Added more tests to the files in the datetime folder * Updated tests suites according to feedback received * Corrected the lint error * Removed repetitive code
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
parseDuration,
|
||||
isValidDuration,
|
||||
isValidGoDuration,
|
||||
durationToMilliseconds,
|
||||
} from './durationutil';
|
||||
|
||||
describe('Duration util', () => {
|
||||
@@ -66,4 +67,15 @@ describe('Duration util', () => {
|
||||
expect(isValidGoDuration(durationString)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('durationToMilliseconds', () => {
|
||||
it('converts a duration to milliseconds', () => {
|
||||
const duration = { hours: 1, minutes: 30, seconds: 45 };
|
||||
|
||||
const now = new Date('2023-07-12');
|
||||
const result = addDurationToDate(now, duration).getTime() - now.getTime();
|
||||
|
||||
expect(result).toEqual(durationToMilliseconds(duration));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user