40 lines · 1.5 KB · TypeScript
RawDownload
import { assert, it } from "@effect/vitest";import * as Deferred from "effect/Deferred";import * as Duration from "effect/Duration";import * as Effect from "effect/Effect";import * as Fiber from "effect/Fiber";import * as TestClock from "effect/testing/TestClock"; import { hasCompatibleOrchestrationProtocol, resolveAvailableEditorsForConfig } from "./ws.ts";import { ORCHESTRATION_PROTOCOL_VERSION } from "@t3tools/contracts"; it("accepts only the current orchestration protocol before websocket RPC setup", () => {  assert.isTrue(    hasCompatibleOrchestrationProtocol(      new URL(`https://host.test/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION}`),    ),  );  assert.isFalse(hasCompatibleOrchestrationProtocol(new URL("https://host.test/ws")));  assert.isFalse(    hasCompatibleOrchestrationProtocol(      new URL(`https://host.test/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION - 1}`),    ),  );}); it.effect("does not block server config when editor discovery never resolves", () =>  Effect.gen(function* () {    const discoveryInterrupted = yield* Deferred.make<void>();    const responseFiber = yield* resolveAvailableEditorsForConfig(      Effect.never.pipe(        Effect.onInterrupt(() => Deferred.succeed(discoveryInterrupted, undefined)),      ),    ).pipe(Effect.forkChild);     yield* TestClock.adjust(Duration.seconds(5));     const availableEditors = yield* Fiber.join(responseFiber);    yield* Deferred.await(discoveryInterrupted);    assert.deepEqual(availableEditors, []);  }),);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t