25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import { pendingScaleConfirmed } from './LeftPane';
|
||
|
||
// ISS-001 — the optimistic slider value is cleared exactly when a rendered snapshot confirms
|
||
// it (server scale === pending), never earlier. Clearing at commit time would snap the pointer
|
||
// back to the stale scale for one poll cycle, then jump forward again on the confirming snapshot.
|
||
|
||
describe('pendingScaleConfirmed', () => {
|
||
it('is false while there is no pending value', () => {
|
||
expect(pendingScaleConfirmed(null, 1)).toBe(false);
|
||
expect(pendingScaleConfirmed(null, 64)).toBe(false);
|
||
});
|
||
|
||
it('stays false while the server still reports the stale scale (the ISS-001 window)', () => {
|
||
// User committed 64×; the last rendered snapshot is still at 1× → must NOT clear yet.
|
||
expect(pendingScaleConfirmed(64, 1)).toBe(false);
|
||
expect(pendingScaleConfirmed(32, 8)).toBe(false);
|
||
});
|
||
|
||
it('becomes true exactly when a snapshot carries the pending scale', () => {
|
||
expect(pendingScaleConfirmed(64, 64)).toBe(true);
|
||
expect(pendingScaleConfirmed(1, 1)).toBe(true); // committing the current value confirms immediately
|
||
});
|
||
});
|