Files
golfgame/tests/soak/tests/deferred.test.ts
adlee-was-taken 1565046ab7 feat(soak): core types + Deferred primitive
Establishes the Scenario/Session/Logger/DashboardReporter contracts
the rest of the harness builds on. Deferred is the building block
for RoomCoordinator's host→joiners handoff.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 17:09:36 -04:00

25 lines
661 B
TypeScript

import { describe, it, expect } from 'vitest';
import { deferred } from '../core/deferred';
describe('deferred', () => {
it('resolves with the given value', async () => {
const d = deferred<string>();
d.resolve('hello');
await expect(d.promise).resolves.toBe('hello');
});
it('rejects with the given error', async () => {
const d = deferred<string>();
const err = new Error('boom');
d.reject(err);
await expect(d.promise).rejects.toBe(err);
});
it('ignores second resolve calls', async () => {
const d = deferred<number>();
d.resolve(1);
d.resolve(2);
await expect(d.promise).resolves.toBe(1);
});
});