fix(spec): export Direction, ScrollAction and LongPressAction from the entry

This commit is contained in:
pj committed 2026-08-15 13:31:32 +05:30
1 parent fb57ab2f56
commit 4b22b45b68
2 files changed
+24

No files matched your search

+3
View File
@@ -4,6 +4,7 @@ export type {
Action, Action,
ActionGenerator, ActionGenerator,
AttrSelector, AttrSelector,
Direction,
DoubleTapAction, DoubleTapAction,
EventuallyFormula, EventuallyFormula,
ExceptionRecord, ExceptionRecord,
@@ -13,10 +14,12 @@ export type {
Key, Key,
KnownAttrSelectors, KnownAttrSelectors,
LogEntry, LogEntry,
LongPressAction,
Point, Point,
PressKeyAction, PressKeyAction,
RawAttrs, RawAttrs,
Sampler, Sampler,
ScrollAction,
SelectorPath, SelectorPath,
Snapshots, Snapshots,
State, State,
+21
View File
@@ -29,6 +29,12 @@ import {
weighted, weighted,
whenRoute, whenRoute,
} from "../src/index.ts"; } from "../src/index.ts";
import type {
Action,
Direction,
LongPressAction,
ScrollAction,
} from "../src/index.ts";
import { setSamplerRng } from "../src/actions.ts"; import { setSamplerRng } from "../src/actions.ts";
import { Pcg } from "../src/pcg.ts"; import { Pcg } from "../src/pcg.ts";
import type { GeneratorNode } from "../src/action-tree.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" })]); const node = whenRoute(route, ["home"], () => [Tap({ on: "id:x" })]);
assert.deepEqual((node as { generate: () => unknown }).generate(), []); 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"],
);
});