feat: implement Sleepy sleep diary
This commit is contained in:
18
lib/sleep.test.ts
Normal file
18
lib/sleep.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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 мин');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user