mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-03 03:27:10 +00:00
feat(driver): add escape to the pressKey surface
escape is a key a spec has real use for and no platform could send it. android maps it to KEYCODE_ESCAPE, the ios companion to HID usage 41 and the in-simulator runner to XCUIKeyboardKey.escape, and the Key union accepts it so it can be written at all.
This commit is contained in:
1 parent
4b7a3878ac
commit
da3cc5f68c
12 files changed
+106
-10
No files matched your search
@@ -184,6 +184,7 @@ export type Key =
|
||||
| "home"
|
||||
| "enter"
|
||||
| "tab"
|
||||
| "escape"
|
||||
| "up"
|
||||
| "down"
|
||||
| "left"
|
||||
|
||||
@@ -38,6 +38,7 @@ import type {
|
||||
EventuallyFormula,
|
||||
Extracted,
|
||||
Formula,
|
||||
Key,
|
||||
State,
|
||||
SanderlingRuntime,
|
||||
} from "../src/types.ts";
|
||||
@@ -273,6 +274,26 @@ test("PressKey returns a PressKeyAction descriptor", () => {
|
||||
assert.deepEqual(PressKey({ key: "back" }), { kind: "PressKey", key: "back" });
|
||||
});
|
||||
|
||||
// Every key docs/manual/spec-language.md documents has to be authorable. A key
|
||||
// the type rejects cannot appear in a spec at all, so the requirement it stands
|
||||
// for ("escape discards the edit in progress") is never actuated anywhere.
|
||||
test("PressKey accepts every documented key", () => {
|
||||
const keys: Key[] = [
|
||||
"back",
|
||||
"home",
|
||||
"enter",
|
||||
"tab",
|
||||
"escape",
|
||||
"up",
|
||||
"down",
|
||||
"left",
|
||||
"right",
|
||||
];
|
||||
for (const key of keys) {
|
||||
assert.deepEqual(PressKey({ key }), { kind: "PressKey", key });
|
||||
}
|
||||
});
|
||||
|
||||
test("Wait returns a WaitAction descriptor", () => {
|
||||
assert.deepEqual(Wait({ durationMillis: 500 }), { kind: "Wait", durationMillis: 500 });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user