import { describe, expect, it } from 'vitest'; import type { RedactionApplyResult } from '@embedpdf/engine-core'; import { finishApply, initialRedactionModel, setLastResult, startApply } from '../src/model'; const result: RedactionApplyResult = { scope: { pages: [] }, results: [], removedAnnotationCount: 0, meta: { affectedPages: [], cacheDelta: null, opId: 'op-1', undoable: false }, }; describe('redaction transitions', () => { it('brackets an apply with the applying flag', () => { const idle = initialRedactionModel(); const running = startApply(idle); expect(running.applying).toBe(true); expect(startApply(running)).toBe(running); expect(finishApply(running).applying).toBe(false); expect(finishApply(idle)).toBe(idle); }); it('records the last result and keeps the same state for the same result', () => { const recorded = setLastResult(initialRedactionModel(), result); expect(recorded.lastResult).toBe(result); expect(setLastResult(recorded, result)).toBe(recorded); }); });