Skip to content

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.

TypeScript
function describeKeybindingsHostContract(
  name: string,
  makeHarness: KeybindingsHostHarnessFactory,
  capabilities: readonly KeybindingsHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessKeybindingsHostHarnessFactory

Builds a fresh host over a backend that holds what it is given, once per test.

capabilitiesreadonly KeybindingsHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/keybindings/testing/contract.ts:65

Interfaces#

KeybindingsHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface KeybindingsHostContractBackend
KeybindingsHostContractBackend properties
NameTypeDescription
storedReadonly<Record<string, string>> | null

The stored overrides (action → spec, unknown actions and empty specs included), or null: none stored.

ui/src/keybindings/testing/contract.ts:28

KeybindingsHostContractControlInterface#

Reads the backend and changes it from outside.

TypeScript
interface KeybindingsHostContractControl
KeybindingsHostContractControl properties
NameTypeDescription
store(overrides: Readonly<Record<string, string>> | null) => void

The user edited the stored overrides (null removes them). The host reads them on its next refresh.

stored() => Readonly<Record<string, string>> | null

The overrides stored now, or null.

ui/src/keybindings/testing/contract.ts:34

KeybindingsHostHarnessInterface#

A host built over a backend, the backend's control, and how to tear them down.

TypeScript
interface KeybindingsHostHarness
KeybindingsHostHarness properties
NameTypeDescription
controlKeybindingsHostContractControl

Reads and changes the backend.

hostKeybindingsHost

The host under test.

dispose?() => void

Closes listeners after each test.

ui/src/keybindings/testing/contract.ts:42

Types#

KeybindingsHostCapabilityType#

An optional KeybindingsHost member.

TypeScript
type KeybindingsHostCapability = 'save' | 'openInEditor' | 'location'

ui/src/keybindings/testing/contract.ts:23

KeybindingsHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type KeybindingsHostHarnessFactory = (backend: KeybindingsHostContractBackend) => KeybindingsHostHarness | Promise<KeybindingsHostHarness>

ui/src/keybindings/testing/contract.ts:52