diff --git a/pkg/spec/src/index.ts b/pkg/spec/src/index.ts index 4ac8c31..724e297 100644 --- a/pkg/spec/src/index.ts +++ b/pkg/spec/src/index.ts @@ -4,6 +4,7 @@ export type { Action, ActionGenerator, AttrSelector, + Direction, DoubleTapAction, EventuallyFormula, ExceptionRecord, @@ -13,10 +14,12 @@ export type { Key, KnownAttrSelectors, LogEntry, + LongPressAction, Point, PressKeyAction, RawAttrs, Sampler, + ScrollAction, SelectorPath, Snapshots, State, diff --git a/pkg/spec/test/api.test.ts b/pkg/spec/test/api.test.ts index eb38207..68a3945 100644 --- a/pkg/spec/test/api.test.ts +++ b/pkg/spec/test/api.test.ts @@ -29,6 +29,12 @@ import { weighted, whenRoute, } from "../src/index.ts"; +import type { + Action, + Direction, + LongPressAction, + ScrollAction, +} from "../src/index.ts"; import { setSamplerRng } from "../src/actions.ts"; import { Pcg } from "../src/pcg.ts"; import type { GeneratorNode } from "../src/action-tree.ts"; @@ -397,3 +403,18 @@ test("whenRoute body is skipped for a null route", () => { const node = whenRoute(route, ["home"], () => [Tap({ on: "id:x" })]); assert.deepEqual((node as { generate: () => unknown }).generate(), []); }); + +// The package entry is the only module a spec author can import from, so every +// member of the exported Action union, and the Direction needed to build a +// Scroll, has to be reachable there rather than only from src/types.ts. +test("index exports every action type a spec author annotates with", () => { + const direction: Direction = "down"; + const scroll: ScrollAction = Scroll({ direction, in: "id:list" }); + const longPress: LongPressAction = LongPress({ on: "id:row" }); + const built: Action[] = [scroll, longPress]; + + assert.deepEqual( + built.map(action => action.kind), + ["Scroll", "LongPress"], + ); +});