code-facade.test.ts
This file
Path
packages/project/test/code-facade.test.ts
48 lines · 1.4 KiB · TypeScript
Last changed by
Merge build/comments-project into mainoscabrielbefore adoption49efd2a
History of this fileTake it
Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
lines 1–2why, one step back1import { describe, expect, it } from "@effect/vitest";2import type { ProjectApi } from "@repo/project/project";Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 3why, one step back3import { keyOf, LandedSha, ProjectName } from "@repo/protocol/ids";Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
line 4why, one step back4import { untouchable } from "@repo/testkit/untouchable";Merge branch 'build/912-why-per-line'oscabrielbefore adoption635c3c7
line 5why, one step back5import { Effect, Option } from "effect";Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
line 6why, one step back6Merge branch 'build/912-why-per-line'oscabrielbefore adoption635c3c7
line 7why, one step back7import { codeProjectOf } from "../src/code.ts";Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
lines 8–9why, one step back8import { CodeCache } from "../src/code/cache.ts";9Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 10why, one step back10const project = ProjectName.make("alice/datekit");Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
lines 11–26why, one step back1112const landed = LandedSha.make("4".repeat(40));1314const api = untouchable<ProjectApi>("ProjectApi", {15 forks: () => Effect.succeed([]),16 head: () => Effect.succeed({ landed }),17 landings: () => Effect.succeed([]),18});1920const code = codeProjectOf(api, project);2122describe("a project's code, read through the façade", () => {23 it.effect(24 "reads the canonical repo, with main from the project's record",25 () =>26 Effect.gen(function* () {Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 27why, one step back27 expect(code.repo).toBe(keyOf(project));Add the code-browser, policy and drafting contracts, peeled tags and commit times on the port, and the AI bindingoscabrielbefore adoptionfc4691d
lines 28–48why, one step back28 expect(yield* code.head).toStrictEqual(Option.some(landed));29 expect(yield* code.forks).toStrictEqual([]);30 })31 );3233 it.effect("caches nothing until a cache is given", () =>34 Effect.gen(function* () {35 const cache = yield* CodeCache;36 let reads = 0;3738 const read = Effect.sync(() => {39 reads += 1;4041 return reads;42 });4344 expect(yield* cache.through("datekit:tree:x", read)).toBe(1);45 expect(yield* cache.through("datekit:tree:x", read)).toBe(2);46 })47 );48});