-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathreadiness.test.ts
More file actions
60 lines (44 loc) · 2 KB
/
readiness.test.ts
File metadata and controls
60 lines (44 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { Effect, Fiber } from "effect";
import { describe, expect, it } from "vitest";
import { makeServerReadiness } from "./readiness";
describe("makeServerReadiness", () => {
it("stays pending until all readiness markers complete", async () => {
await Effect.runPromise(
Effect.gen(function* () {
const readiness = yield* makeServerReadiness;
const readyFiber = yield* readiness.awaitServerReady.pipe(Effect.forkScoped);
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markHttpListening;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markPushBusReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markKeybindingsReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markTerminalSubscriptionsReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markOrchestrationSubscriptionsReady;
yield* Fiber.join(readyFiber);
expect(readyFiber.pollUnsafe()).not.toBeUndefined();
}).pipe(Effect.scoped),
);
});
it("resolves regardless of the order markers complete", async () => {
await Effect.runPromise(
Effect.gen(function* () {
const readiness = yield* makeServerReadiness;
const readyFiber = yield* readiness.awaitServerReady.pipe(Effect.forkScoped);
yield* readiness.markOrchestrationSubscriptionsReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markTerminalSubscriptionsReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markKeybindingsReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markPushBusReady;
expect(readyFiber.pollUnsafe()).toBeUndefined();
yield* readiness.markHttpListening;
yield* Fiber.join(readyFiber);
expect(readyFiber.pollUnsafe()).not.toBeUndefined();
}).pipe(Effect.scoped),
);
});
});