untouchable.test.ts
This file
Path
packages/testkit/test/untouchable.test.ts
38 lines · 989 bytes · TypeScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–38why, one step back1import { describe, expect, it } from "@effect/vitest";2import { Effect } from "effect";34import { TouchedError, untouchable } from "../src/untouchable.ts";56interface Counter {7 readonly count: () => number;8 readonly reset: () => void;9}1011describe(untouchable, () => {12 it("throws on any member a test did not give, naming it", () => {13 const counter = untouchable<Counter>("COUNTER");1415 expect(() => {16 counter.reset();17 }).toThrow(new TouchedError("COUNTER", "reset"));18 });1920 it("reads the members a test gave", () => {21 const counter = untouchable<Counter>("COUNTER", { count: () => 3 });2223 expect(counter.count()).toBe(3);24 expect(() => {25 counter.reset();26 }).toThrow(TouchedError);27 });2829 it.effect("resolves a promise without a read", () =>30 Effect.gen(function* () {31 const counter = untouchable<Counter>("COUNTER");3233 expect(yield* Effect.promise(() => Promise.resolve(counter))).toBe(34 counter35 );36 })37 );38});