Skip to content

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.

TypeScript
function contractView(sessionId: string, id: string, createdAt: number): StoredView
Parameters
NameTypeDescription
sessionIdstring

The view's session.

idstring

The view's id.

createdAtnumber

When the view was made, in milliseconds.

ui/src/views/testing/contract.ts:97

describeViewsHostContractFunction#

Declares the shared ViewsHost suite for one implementation.

TypeScript
function describeViewsHostContract(
  name: string,
  makeHarness: ViewsHostHarnessFactory,
  capabilities: readonly ViewsHostCapability[],
): void
Parameters
NameTypeDescription
namestring

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

makeHarnessViewsHostHarnessFactory

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

capabilitiesreadonly ViewsHostCapability[]

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

ui/src/views/testing/contract.ts:132

Interfaces#

ViewsHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface ViewsHostContractBackend
ViewsHostContractBackend properties
NameTypeDescription
refreshboolean

The host can refresh views.

viewsreadonly StoredView[]

The stored views, of any session.

ui/src/views/testing/contract.ts:58

ViewsHostContractControlInterface#

Reads the backend and changes it from outside.

TypeScript
interface ViewsHostContractControl
ViewsHostContractControl properties
NameTypeDescription
add(view: StoredView) => void

The host stored a view (a turn ended) and sent views:changed.

problems?(sessionId: string, id: string) => readonly ViewProblem[]

The problems the backend got for a view, in order. Needed with reportProblem.

view(sessionId: string, id: string) => StoredView | undefined

The view stored now, or undefined.

ui/src/views/testing/contract.ts:66

ViewsHostHarnessInterface#

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

TypeScript
interface ViewsHostHarness
ViewsHostHarness properties
NameTypeDescription
controlViewsHostContractControl

Reads and changes the backend from outside.

dispose?() => void

Tears down the host and its backend.

hostViewsHost

The host under test.

ui/src/views/testing/contract.ts:76

Types#

ViewsHostCapabilityType#

An optional ViewsHost member.

TypeScript
type ViewsHostCapability =
  | 'meta'
  | 'get'
  | 'setHeights'
  | 'refresh'
  | 'subscribe'
  | 'customFrame'
  | 'reportProblem'
  | 'saved'

ui/src/views/testing/contract.ts:38

ViewsHostHarnessFactoryType#

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

TypeScript
type ViewsHostHarnessFactory = (backend: ViewsHostContractBackend) => ViewsHostHarness | Promise<ViewsHostHarness>

ui/src/views/testing/contract.ts:86