zidane-ui/ keybindings/ testing/ contract
import { … } from 'zidane-ui/keybindings/testing/contract'ui/src/keybindings/testing/contract.ts
Functions#
describeKeybindingsHostContractFunction#
Declares the shared KeybindingsHost suite for one implementation.
function describeKeybindingsHostContract(
name: string,
makeHarness: KeybindingsHostHarnessFactory,
capabilities: readonly KeybindingsHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | KeybindingsHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly KeybindingsHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
KeybindingsHostContractBackendInterface#
What the backend behind the host holds.
interface KeybindingsHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| stored | Readonly<Record<string, string>> | null | The stored overrides (action → spec, unknown actions and empty specs included), or |
KeybindingsHostContractControlInterface#
Reads the backend and changes it from outside.
interface KeybindingsHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| store | (overrides: Readonly<Record<string, string>> | null) => void | The user edited the stored overrides ( |
| stored | () => Readonly<Record<string, string>> | null | The overrides stored now, or |
KeybindingsHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface KeybindingsHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | KeybindingsHostContractControl | Reads and changes the backend. |
| host | KeybindingsHost | The host under test. |
| dispose? | () => void | Closes listeners after each test. |
Types#
KeybindingsHostCapabilityType#
An optional KeybindingsHost member.
type KeybindingsHostCapability = 'save' | 'openInEditor' | 'location'KeybindingsHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type KeybindingsHostHarnessFactory = (backend: KeybindingsHostContractBackend) => KeybindingsHostHarness | Promise<KeybindingsHostHarness>