| 1 | import { expect, it } from "@effect/vitest"; |
| 2 | import * as Deferred from "effect/Deferred"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | |
| 5 | import * as ServerActivation from "./serverActivation.ts"; |
| 6 | |
| 7 | it.effect("proves a root is parked before returning and releases it with one gate", () => |
| 8 | Effect.scoped( |
| 9 | Effect.gen(function* () { |
| 10 | const activation = yield* Deferred.make<void>(); |
| 11 | const ran = yield* Deferred.make<void>(); |
| 12 | |
| 13 | yield* ServerActivation.forkParked(Deferred.succeed(ran, undefined)).pipe( |
| 14 | Effect.provideService(ServerActivation.ServerActivation, Deferred.await(activation)), |
| 15 | ); |
| 16 | expect(yield* Deferred.isDone(ran)).toBe(false); |
| 17 | |
| 18 | yield* Deferred.succeed(activation, undefined); |
| 19 | yield* Deferred.await(ran); |
| 20 | expect(yield* Deferred.isDone(ran)).toBe(true); |
| 21 | }), |
| 22 | ), |
| 23 | ); |