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.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192/** Tests for the shared test-scheduling helpers. @module */
import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { createGate, yieldTurn,} from './test-support.ts';
await describe({ name: '', children: [ describe({ name: createGate.name, children: [ it({ name: 'keeps the gate promise pending until released', fn: async () => { const gate = createGate(); /** Whether the gate promise settled before the release. */ const state = { settled: false, }; /** Observes the gate promise settling without awaiting it in the test body. */ async function observeSettled(): Promise<void> { await gate.open; state.settled = true; } void observeSettled(); await yieldTurn(); expect(state.settled,).toBe(false,); }, },),
it({ name: 'settles the gate promise once released', fn: async () => { const gate = createGate(); gate.release(); /** Result of awaiting the released gate. */ const result = await gate.open; expect(result,).toBeUndefined(); }, },), ], },),
describe({ name: yieldTurn.name, children: [ it({ name: 'resolves to undefined after a full turn', fn: async () => { const result = await yieldTurn(); expect(result,).toBeUndefined(); }, },),
it({ name: 'spans a macrotask turn, letting earlier timers fire first', fn: async () => { /** Flag set by a timer scheduled before the turn under test. */ const state = { timerFired: false, }; setTimeout(function markFired(): void { state.timerFired = true; }, 0, ); await yieldTurn(); expect(state.timerFired,).toBe(true,); }, },), ], },), ],},);