implementing Mgrdich's suggestion

This commit is contained in:
Mihai 2023-08-31 14:15:12 +03:00
parent 387554ebdb
commit 23d937a94c

View file

@ -12,20 +12,12 @@ describe('dateTimeHelpers', () => {
it('should output the correct date', () => {
const date = new Date();
const formattedDate = formatTimestamp(date);
const formattedTimestamp = formatTimestamp(date.getTime());
const expected = `${
date.getMonth() + 1
}/${date.getDate()}/${date.getFullYear()}, ${date
.getHours()
.toString()
.padStart(2, '0')}:${date
.getMinutes()
.toString()
.padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`;
expect(formattedDate).toBe(expected);
expect(formattedTimestamp).toBe(expected);
expect(formatTimestamp(date)).toBe(
date.toLocaleString([], { hourCycle: 'h23' })
);
expect(formatTimestamp(date.getTime())).toBe(
date.toLocaleString([], { hourCycle: 'h23' })
);
});
});
});