Do not watch tests & fix time formatting
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "vitest",
|
||||
"test": "vitest run",
|
||||
"test:all": "vitest run && npx playwright test",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
|
||||
},
|
||||
|
||||
@@ -110,3 +110,18 @@ export function timeToMinutes(timeStr: string): number {
|
||||
const [hours, minutes] = timeStr.split(":").map(Number);
|
||||
return hours * 60 + minutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert total minutes to a human-readable string (e.g., "1h 30m" or "45m")
|
||||
* @param totalMinutes - Total number of minutes
|
||||
* @returns Formatted string
|
||||
*/
|
||||
export function formatMinutes(totalMinutes: number): string {
|
||||
const hours = Math.floor(totalMinutes / 60);
|
||||
const mins = totalMinutes % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}h ${mins}m`;
|
||||
}
|
||||
return `${mins}m`;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ describe('formatMinutes', () => {
|
||||
});
|
||||
|
||||
it('formats hours only', () => {
|
||||
expect(formatMinutes(120)).toBe('2h');
|
||||
expect(formatMinutes(120)).toBe('2h 0m');
|
||||
});
|
||||
|
||||
it('formats minutes only', () => {
|
||||
|
||||
Reference in New Issue
Block a user