From b23a8efbdbe574384f1a6321c858c87c4182958d Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 31 May 2026 18:09:34 +0530 Subject: [PATCH] test(spec): cover LongPress and Scroll runtime members --- pkg/spec/test/api.test.ts | 4 ++++ pkg/spec/test/defaults.test.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/spec/test/api.test.ts b/pkg/spec/test/api.test.ts index b5e8eb7..565683e 100644 --- a/pkg/spec/test/api.test.ts +++ b/pkg/spec/test/api.test.ts @@ -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: () => [] }, diff --git a/pkg/spec/test/defaults.test.ts b/pkg/spec/test/defaults.test.ts index a2ee6f9..9c471b6 100644 --- a/pkg/spec/test/defaults.test.ts +++ b/pkg/spec/test/defaults.test.ts @@ -59,12 +59,16 @@ function installRuntime(initialState: State): RecordedRuntime { from: (_items: readonly T[]): Sampler => ({ 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");