test(spec): cover LongPress and Scroll runtime members

This commit is contained in:
pj committed 2026-05-31 18:09:34 +05:30
1 parent 792010c6d0
commit b23a8efbdb
2 files changed
+15

No files matched your search

+4
View File
@@ -143,6 +143,8 @@ function installFakeRuntime(): RecordedRuntime {
},
tap: ({ on }) => ({ kind: "Tap", on }),
doubleTap: ({ on }) => ({ kind: "DoubleTap", on }),
longPress: ({ on }) => ({ kind: "LongPress", on }),
scroll: ({ direction, in: container }) => ({ kind: "Scroll", direction, in: container }),
inputText: ({ into, text }) => ({ kind: "InputText", into, text }),
swipe: ({ from: fromPoint, to, durationMillis }) => ({
kind: "Swipe",
@@ -154,6 +156,8 @@ function installFakeRuntime(): RecordedRuntime {
wait: ({ durationMillis }) => ({ kind: "Wait", durationMillis }),
taps: { __sanderlingActionGenerator: true, generate: () => [] },
doubleTaps: { __sanderlingActionGenerator: true, generate: () => [] },
longPresses: { __sanderlingActionGenerator: true, generate: () => [] },
scrolls: { __sanderlingActionGenerator: true, generate: () => [] },
typing: { __sanderlingActionGenerator: true, generate: () => [] },
swipes: { __sanderlingActionGenerator: true, generate: () => [] },
waitOnce: { __sanderlingActionGenerator: true, generate: () => [] },
+11
View File
@@ -59,12 +59,16 @@ function installRuntime(initialState: State): RecordedRuntime {
from: <T>(_items: readonly T[]): Sampler<T> => ({ generate: () => _items[0] as T }),
tap: ({ on }) => ({ kind: "Tap", on }),
doubleTap: ({ on }) => ({ kind: "DoubleTap", on }),
longPress: ({ on }) => ({ kind: "LongPress", on }),
scroll: ({ direction, in: container }) => ({ kind: "Scroll", direction, in: container }),
inputText: ({ into, text }) => ({ kind: "InputText", into, text }),
swipe: (p) => ({ kind: "Swipe", from: p.from, to: p.to, durationMillis: p.durationMillis }),
pressKey: ({ key }) => ({ kind: "PressKey", key }),
wait: ({ durationMillis }) => ({ kind: "Wait", durationMillis }),
taps: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
doubleTaps: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
longPresses: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
scrolls: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
typing: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
swipes: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
waitOnce: { __sanderlingActionGenerator: true, generate: () => [] } as ActionGenerator,
@@ -125,6 +129,13 @@ test("typing resolves as a valid ActionGenerator", async () => {
assert.equal(typing.__sanderlingActionGenerator, true);
});
test("longPresses and scrolls resolve as valid ActionGenerators", async () => {
installRuntime(emptyState);
const { longPresses, scrolls } = await import("../src/defaults/actions.ts");
assert.equal(longPresses.__sanderlingActionGenerator, true);
assert.equal(scrolls.__sanderlingActionGenerator, true);
});
test("defaults barrel re-exports both properties and actions", async () => {
installRuntime(emptyState);
const barrel = await import("../src/defaults/index.ts");