zidane-ui/ views/ testing/ contract
import { … } from 'zidane-ui/views/testing/contract'ui/src/views/testing/contract.ts
Functions#
contractViewFunction#
A stored view of the suite's backends.
function contractView(sessionId: string, id: string, createdAt: number): StoredViewParameters
| Name | Type | Description |
|---|---|---|
| sessionId | string | The view's session. |
| id | string | The view's id. |
| createdAt | number | When the view was made, in milliseconds. |
Returns
describeViewsHostContractFunction#
Declares the shared ViewsHost suite for one implementation.
function describeViewsHostContract(
name: string,
makeHarness: ViewsHostHarnessFactory,
capabilities: readonly ViewsHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | ViewsHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly ViewsHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
ViewsHostContractBackendInterface#
What the backend behind the host holds.
interface ViewsHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| refresh | boolean | The host can refresh views. |
| views | readonly StoredView[] | The stored views, of any session. |
ViewsHostContractControlInterface#
Reads the backend and changes it from outside.
interface ViewsHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| add | (view: StoredView) => void | The host stored a view (a turn ended) and sent |
| problems? | (sessionId: string, id: string) => readonly ViewProblem[] | The problems the backend got for a view, in order. Needed with |
| view | (sessionId: string, id: string) => StoredView | undefined | The view stored now, or |
ViewsHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface ViewsHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | ViewsHostContractControl | Reads and changes the backend from outside. |
| dispose? | () => void | Tears down the host and its backend. |
| host | ViewsHost | The host under test. |
Types#
ViewsHostCapabilityType#
An optional ViewsHost member.
type ViewsHostCapability =
| 'meta'
| 'get'
| 'setHeights'
| 'refresh'
| 'subscribe'
| 'customFrame'
| 'reportProblem'
| 'saved'ViewsHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type ViewsHostHarnessFactory = (backend: ViewsHostContractBackend) => ViewsHostHarness | Promise<ViewsHostHarness>