19 lines
614 B
TypeScript
19 lines
614 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { calculateMetrics, formatDuration } from './sleep';
|
|
|
|
describe('sleep calculations', () => {
|
|
it('calculates overnight time in bed, total sleep, and efficiency', () => {
|
|
expect(calculateMetrics({
|
|
bedtime: '23:40',
|
|
riseTime: '07:10',
|
|
sleepLatencyMinutes: 30,
|
|
wasoMinutes: 40,
|
|
})).toEqual({ timeInBedMinutes: 450, totalSleepMinutes: 380, efficiency: 84 });
|
|
});
|
|
|
|
it('formats a duration for the summary', () => {
|
|
expect(formatDuration(380)).toBe('6 ч 20 мин');
|
|
expect(formatDuration(5)).toBe('5 мин');
|
|
});
|
|
});
|