docs: restore coding on steroids narrative with future-betting manifesto in all READMEs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, spyOn } from "bun:test"
|
||||
import { createEventState, serializeError, type EventState } from "./events"
|
||||
import { createEventState, processEvents, serializeError, type EventState } from "./events"
|
||||
import type { RunContext, EventPayload } from "./types"
|
||||
|
||||
const createMockContext = (sessionID: string = "test-session"): RunContext => ({
|
||||
@@ -99,7 +99,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -121,7 +120,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -144,7 +142,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -164,7 +161,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -184,7 +180,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -207,7 +202,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -229,7 +223,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
//#when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -251,7 +244,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -275,7 +267,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -299,7 +290,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
@@ -328,7 +318,6 @@ describe("event handling", () => {
|
||||
}
|
||||
|
||||
const events = toAsyncIterable([payload])
|
||||
const { processEvents } = await import("./events")
|
||||
|
||||
// when
|
||||
await processEvents(ctx, events, state)
|
||||
|
||||
@@ -11,17 +11,17 @@ interface FakeTimeouts {
|
||||
restore: () => void
|
||||
}
|
||||
|
||||
// Capture the real implementations at module load time, before any test can patch them.
|
||||
// This ensures restore() always returns to the true originals regardless of test execution order.
|
||||
const TRUE_ORIGINAL_SET_TIMEOUT = globalThis.setTimeout
|
||||
const TRUE_ORIGINAL_CLEAR_TIMEOUT = globalThis.clearTimeout
|
||||
|
||||
function createFakeTimeouts(): FakeTimeouts {
|
||||
let now = 0
|
||||
let nextId = 1
|
||||
const timers = new Map<number, { id: number; time: number; callback: TimerCallback; args: any[] }>()
|
||||
const cleared = new Set<number>()
|
||||
|
||||
const original = {
|
||||
setTimeout: globalThis.setTimeout,
|
||||
clearTimeout: globalThis.clearTimeout,
|
||||
}
|
||||
|
||||
const normalizeDelay = (delay?: number) => {
|
||||
if (typeof delay !== "number" || !Number.isFinite(delay)) return 0
|
||||
return delay < 0 ? 0 : delay
|
||||
@@ -68,8 +68,8 @@ function createFakeTimeouts(): FakeTimeouts {
|
||||
}
|
||||
|
||||
const restore = () => {
|
||||
globalThis.setTimeout = original.setTimeout
|
||||
globalThis.clearTimeout = original.clearTimeout
|
||||
globalThis.setTimeout = TRUE_ORIGINAL_SET_TIMEOUT
|
||||
globalThis.clearTimeout = TRUE_ORIGINAL_CLEAR_TIMEOUT
|
||||
}
|
||||
|
||||
return { advanceBy, restore }
|
||||
|
||||
Reference in New Issue
Block a user