iterate.com / cloud

git clone https://git.iterate.com/repos/cloud

cloud / internal-packages / cloud-clients / src / test-workers.tsmain at aacbc74

// test-workers.ts — `cloudflare:workers` for the tests, which run in Node: a Durable Object is its
// state and its environment, and the tests hand it a state backed by a Map (worker.test.ts).
export class DurableObject<Env = unknown> {
  ctx: DurableObjectState;
  env: Env;
  constructor(ctx: DurableObjectState, env: Env) {
    this.ctx = ctx;
    this.env = env;
  }
}

/** What the Worker left to end after its answer (`waitUntil`): a test awaits these and empties it. */
export const waited: Promise<unknown>[] = [];
export const waitUntil = (work: Promise<unknown>) => void waited.push(work);