feat(core): add secure recipe APIs, precise scaling and versioned imports
This commit is contained in:
commit
5d71d32e20
31 files changed
+6293
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { startTimer, pauseTimer, remainingMs } from '../../src/lib/cooking';
|
||||
describe('Timestamp-based kitchen timers', () => {
|
||||
it('does not display an extra second when the last render predates the start', () => {
|
||||
expect(remainingMs(startTimer({ remaining: 60000, endAt: null }, 1200), 1000)).toBe(60000);
|
||||
});
|
||||
it('starts with an absolute deadline, not ticking state', () => {
|
||||
expect(startTimer({ remaining: 60000, endAt: null }, 1000).endAt).toBe(61000);
|
||||
});
|
||||
it('survives navigation, sleep and serialized progress', () => {
|
||||
const timer = JSON.parse(JSON.stringify(startTimer({ remaining: 60000, endAt: null }, 1000)));
|
||||
expect(remainingMs(timer, 41000)).toBe(20000);
|
||||
expect(remainingMs(timer, 90000)).toBe(0);
|
||||
});
|
||||
it('pauses precisely and resumes without drift', () => {
|
||||
const paused = pauseTimer(startTimer({ remaining: 60000, endAt: null }, 1000), 21000);
|
||||
expect(remainingMs(paused, 90000)).toBe(40000);
|
||||
expect(remainingMs(startTimer(paused, 90000), 100000)).toBe(30000);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user