mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 02:32:15 +01:00
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { formatHumanReadableDuration, formatReportingDuration } from './time';
|
|
|
|
const seconds = 14 * 3600 + 45 * 60 + 6; // 14h 45m 06s
|
|
|
|
describe('formatHumanReadableDuration', () => {
|
|
test('decimal', () => {
|
|
expect(formatHumanReadableDuration(seconds, 'decimal', 'comma-point')).toBe('14.75 h');
|
|
});
|
|
|
|
test('hours-minutes', () => {
|
|
expect(formatHumanReadableDuration(seconds, 'hours-minutes')).toBe('14h 45min');
|
|
});
|
|
|
|
test('hours-minutes-colon-separated', () => {
|
|
expect(formatHumanReadableDuration(seconds, 'hours-minutes-colon-separated')).toBe('14:45');
|
|
});
|
|
|
|
test('hours-minutes-seconds-colon-separated', () => {
|
|
expect(formatHumanReadableDuration(seconds, 'hours-minutes-seconds-colon-separated')).toBe(
|
|
'14:45:06'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('formatReportingDuration', () => {
|
|
test('decimal', () => {
|
|
expect(formatReportingDuration(seconds, 'decimal', 'comma-point')).toBe('14.75 h');
|
|
});
|
|
|
|
test('hours-minutes', () => {
|
|
expect(formatReportingDuration(seconds, 'hours-minutes')).toBe('14:45:06');
|
|
});
|
|
|
|
test('hours-minutes-colon-separated', () => {
|
|
expect(formatReportingDuration(seconds, 'hours-minutes-colon-separated')).toBe('14:45:06');
|
|
});
|
|
|
|
test('hours-minutes-seconds-colon-separated', () => {
|
|
expect(formatReportingDuration(seconds, 'hours-minutes-seconds-colon-separated')).toBe(
|
|
'14:45:06'
|
|
);
|
|
});
|
|
});
|