zidane-ui/ workspace/ testing/ contract
import { … } from 'zidane-ui/workspace/testing/contract'ui/src/workspace/testing/contract.ts
Functions#
describeWorkspaceHostContractFunction#
Declares the shared WorkspaceHost suite for one implementation.
function describeWorkspaceHostContract<S extends WorkspaceScope>(
name: string,
makeHarness: WorkspaceHostHarnessFactory<S>,
capabilities: readonly WorkspaceHostCapability[],
): voidType parameters
| Name | Type | Description |
|---|---|---|
| S | extends WorkspaceScope |
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | WorkspaceHostHarnessFactory<S> | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly WorkspaceHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
WorkspaceHostContractBackendInterface#
What the backend behind the host holds.
interface WorkspaceHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| content | Readonly<Record<string, PanelContent>> | Each panel's content, by id; a panel missing here fails to load. |
| cwd | string | The folder the extension panels are offered in (no other folder offers any). |
| failingAction | { actionId: string; message: string; panelId: string } | The one action that fails, with the extension's words; every other action succeeds. |
| layouts | Readonly<Record<string, WorkspaceLayout>> | The layouts stored per scope key (a key missing here has nothing stored). |
| panels | readonly WorkspacePanelSummary[] | The extension panels offered in |
WorkspaceHostContractControlInterface#
Changes the backend from outside and announces it as the backend does.
interface WorkspaceHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| changeCatalog | () => void | An extension loaded or left: the catalog may have changed. |
| changePanel | (cwd: string, panelId: string) => void | A panel's content changed in |
| writeLayout | (key: string, layout: WorkspaceLayout) => void | Another window stored |
WorkspaceHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface WorkspaceHostHarness<S extends WorkspaceScope = WorkspaceScope>Type parameters
| Name | Type | Default | Description |
|---|---|---|---|
| S | extends WorkspaceScope | WorkspaceScope |
Properties
| Name | Type | Description |
|---|---|---|
| control | WorkspaceHostContractControl | Changes the backend from outside. |
| host | WorkspaceHost<S> | The host under test. |
| dispose? | () => void | Closes connections and timers after each test. |
| scope | (key: string) => S | The scope the host takes for a scope key. |
Types#
WorkspaceHostCapabilityType#
An optional WorkspaceHost member, by its path.
type WorkspaceHostCapability =
| 'layouts'
| 'panels'
| 'panels.watch'
| 'panels.subscribe'
| 'panels.subscribeCatalog'WorkspaceHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type WorkspaceHostHarnessFactory<S extends WorkspaceScope = WorkspaceScope> = (backend: WorkspaceHostContractBackend) => WorkspaceHostHarness<S> | Promise<WorkspaceHostHarness<S>>Type parameters
| Name | Type | Default | Description |
|---|---|---|---|
| S | extends WorkspaceScope | WorkspaceScope |