mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-13 18:52:14 +01:00
add timesheet unit and e2e tests; add unit test CI setup
This commit is contained in:
44
resources/js/packages/ui/src/utils/time.test.ts
Normal file
44
resources/js/packages/ui/src/utils/time.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user