Download packages/schema/test/event.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/schema/test/event.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/schema/test/event.test.ts
-
curl -L -o event.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/schema/test/event.test.ts
1.25 kB
| import { describe, expect, test } from "bun:test" | |
| import { Schema } from "effect" | |
| import { Event } from "../src/event" | |
| describe("public event schemas", () => { | |
| test("definition is pure", () => { | |
| const definitions = Event.inventory() | |
| Event.define({ type: "test.pure", schema: { value: Schema.String } }) | |
| expect(definitions).toEqual([]) | |
| }) | |
| test("latest selection is independent of declaration order", () => { | |
| const historical = Event.define({ | |
| type: "test.versioned", | |
| durable: { aggregate: "id", version: 1 }, | |
| schema: { id: Schema.String }, | |
| }) | |
| const current = Event.define({ | |
| type: "test.versioned", | |
| durable: { aggregate: "id", version: 2 }, | |
| schema: { id: Schema.String, value: Schema.String }, | |
| }) | |
| expect(Event.latest([historical, current]).get(current.type)).toBe(current) | |
| expect(Event.latest([current, historical]).get(current.type)).toBe(current) | |
| }) | |
| test("durable definitions are indexed by type and version", () => { | |
| const definition = Event.define({ | |
| type: "test.durable", | |
| durable: { aggregate: "id", version: 1 }, | |
| schema: { id: Schema.String }, | |
| }) | |
| expect(Event.durable([definition]).get("test.durable.1")).toBe(definition) | |
| }) | |
| }) | |