Files
t3code/packages/client-runtime/src/environmentRuntimeState.test.ts
T
Julius Marminge 131f25ce8f Update ESLint configuration, remove unused dependencies, and refactor connection handling
- Added "apps/mobile/uniwind-types.d.ts" to .oxlintrc.json ignore list.
- Disabled the "unicorn/no-array-sort" rule in ESLint.
- Removed "zustand" from bun.lock and package.json.
- Refactored connection handling in various components, including the introduction of ConnectionSheetButton and updates to connection-related functions.
- Updated type imports to use EnvironmentScoped types across multiple files.
- Cleaned up unused imports and improved code structure in several components.
2026-04-13 18:26:36 -07:00

75 lines
1.8 KiB
TypeScript

import { AtomRegistry } from "effect/unstable/reactivity";
import { afterEach, describe, expect, it } from "vitest";
import { createEnvironmentRuntimeManager } from "./environmentRuntimeState";
let atomRegistry = AtomRegistry.make();
function resetAtomRegistry() {
atomRegistry.dispose();
atomRegistry = AtomRegistry.make();
}
const TARGET = { environmentId: "env-local" } as const;
describe("createEnvironmentRuntimeManager", () => {
afterEach(() => {
resetAtomRegistry();
});
it("stores state per environment", () => {
const manager = createEnvironmentRuntimeManager({
getRegistry: () => atomRegistry,
});
manager.setState(TARGET, {
connectionState: "ready",
connectionError: null,
serverConfig: null,
});
expect(manager.getSnapshot(TARGET)).toEqual({
connectionState: "ready",
connectionError: null,
serverConfig: null,
});
});
it("patches the current state", () => {
const manager = createEnvironmentRuntimeManager({
getRegistry: () => atomRegistry,
});
manager.patch(TARGET, (current) => ({
...current,
connectionState: "disconnected",
connectionError: "Socket closed.",
}));
expect(manager.getSnapshot(TARGET)).toEqual({
connectionState: "disconnected",
connectionError: "Socket closed.",
serverConfig: null,
});
});
it("invalidates a single environment", () => {
const manager = createEnvironmentRuntimeManager({
getRegistry: () => atomRegistry,
});
manager.setState(TARGET, {
connectionState: "ready",
connectionError: null,
serverConfig: null,
});
manager.invalidate(TARGET);
expect(manager.getSnapshot(TARGET)).toEqual({
connectionState: "idle",
connectionError: null,
serverConfig: null,
});
});
});