zidane-ui/ terminal/ testing/ contract
import { … } from 'zidane-ui/terminal/testing/contract'ui/src/terminal/testing/contract.ts
Functions#
describeTerminalHostContractFunction#
Declares the shared TerminalHost suite for one implementation.
function describeTerminalHostContract(
name: string,
makeHarness: TerminalHostHarnessFactory,
capabilities: readonly TerminalHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | TerminalHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly TerminalHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
TerminalHostContractBackendInterface#
What the backend behind the host holds.
interface TerminalHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| drafts | Readonly<Record<string, readonly TerminalInfo[]>> | The terminals per draft id (no session yet). |
| history | Readonly<Record<string, string>> | What each terminal printed so far, by id. |
| sessions | Readonly<Record<string, readonly TerminalInfo[]>> | The terminals per session id. |
TerminalHostContractControlInterface#
Reads the backend and acts from outside.
interface TerminalHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| announce | (sessionId: string) => void | The backend sends a session's full list (as after any change). |
(terminalId: string, data: string) => void | The terminal prints | |
| relink? | () => void | The link to the backend drops and comes back. Absent: it never drops. |
| terminals | () => TerminalInfo[] | Every terminal the backend holds now. |
| writes | (terminalId: string) => string[] | The typing a terminal received, one entry per write. |
TerminalHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface TerminalHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | TerminalHostContractControl | Reads and acts on the backend. |
| host | TerminalHost | The host under test. |
| dispose? | () => void | Closes connections and listeners after each test. |
Types#
TerminalHostCapabilityType#
An optional TerminalHost member.
type TerminalHostCapability =
| 'restart'
| 'setHidden'
| 'adoptDraft'
| 'releaseDraft'
| 'layouts'TerminalHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type TerminalHostHarnessFactory = (backend: TerminalHostContractBackend) => TerminalHostHarness | Promise<TerminalHostHarness>