import { shouldFlushMemory } from '../memoryFlushPhase'; describe('shouldFlushMemory', () => { // Use upstream-aligned defaults: soft=4000, reserve=20000 means a 200k // window fires at 176k. Explicit numbers here keep the test independent // from the constants file. const base = { windowTokens: 200_000, reserveFloorTokens: 20_000, softThresholdTokens: 4_000, }; it('returns false far from the window', () => { expect(shouldFlushMemory({ ...base, currentTokens: 100_000 })).toBe(false); }); it('returns true exactly at the threshold', () => { // window - reserve - soft = 176_000 expect(shouldFlushMemory({ ...base, currentTokens: 176_000 })).toBe(true); }); it('returns true past the threshold', () => { expect(shouldFlushMemory({ ...base, currentTokens: 190_000 })).toBe(true); }); it('returns false for non-finite inputs', () => { expect(shouldFlushMemory({ ...base, currentTokens: Number.NaN })).toBe( false ); }); it('returns false when window is zero', () => { expect(shouldFlushMemory({ currentTokens: 100, windowTokens: 0 })).toBe( false ); }); });