Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { createPublicationInterruptControl, type PublicationSignalHost,} from '../dist/final/node/index.mjs';
await describe({ name: createPublicationInterruptControl.name, children: [ it({ name: 'stops on first interrupt and forces on second', fn: async () => { /** Mutable fake signal host state. */ const state: { listener?: () => void; forced: number; removed: number; } = { forced: 0, removed: 0, }; /** Fake process signal host. */ const host: PublicationSignalHost = { onInterrupt(listener,) { state.listener = listener; }, offInterrupt() { state.removed += 1; }, forceInterrupt() { state.forced += 1; }, };
{ using control = createPublicationInterruptControl({ host, }); if (state.listener === undefined) { throw new Error('interrupt listener was not installed',); } state.listener(); expect(control.shouldStop(),).toBe(true,); state.listener(); expect(state.forced,).toBe(1,); } expect(state.removed,).toBe(2,); }, },), ],},);