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:
RoxanaAnamariaTurc
2023-07-21 11:24:22 +01:00
committed by GitHub
parent e7ad60bfc7
commit eea18d6741
3 changed files with 105 additions and 5 deletions
@@ -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));
});
});
});