Skip to content

zidane-ui/appearance/testing/contract

import { … } from 'zidane-ui/appearance/testing/contract'ui/src/appearance/testing/contract.ts

Functions#

describeAppearanceHostContractFunction#

Declares the shared AppearanceHost suite for one implementation.

TypeScript
function describeAppearanceHostContract(
  name: string,
  makeHarness: AppearanceHostHarnessFactory,
  capabilities: readonly AppearanceHostCapability[],
): void
Parameters
NameTypeDescription
namestring

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

makeHarnessAppearanceHostHarnessFactory

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

capabilitiesreadonly AppearanceHostCapability[]

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

ui/src/appearance/testing/contract.ts:95

Interfaces#

AppearanceHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface AppearanceHostContractBackend
AppearanceHostContractBackend properties
NameTypeDescription
storedstring | null

The stored preferences blob, or null when nothing is stored (a first run).

themesReadonly<Record<string, readonly Theme[]>>

The extra themes per folder (a folder missing here has none).

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

AppearanceHostContractControlInterface#

Reads the backend and changes it from outside.

TypeScript
interface AppearanceHostContractControl
AppearanceHostContractControl properties
NameTypeDescription
boot?() => BootSnapshot | null

The snapshot the backend holds, or null (hosts with boot).

reopen() => AppearanceHost

A fresh host over the same backend: what a relaunch reads.

stored() => string | null

The blob the backend holds now.

storeExternally(raw: string | null) => void

Another window stored this blob (null clears it), announced as the backend does.

windowCalls?() => readonly AppearanceHostContractWindowCall[]

The window calls the backend saw, in order (hosts with window).

ui/src/appearance/testing/contract.ts:50

AppearanceHostHarnessInterface#

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

TypeScript
interface AppearanceHostHarness
AppearanceHostHarness properties
NameTypeDescription
controlAppearanceHostContractControl

Reads and changes the backend.

hostAppearanceHost

The host under test.

dispose?() => void

Closes listeners after each test.

ui/src/appearance/testing/contract.ts:64

Types#

AppearanceHostCapabilityType#

An optional AppearanceHost member, by its path.

TypeScript
type AppearanceHostCapability =
  | 'themes'
  | 'boot'
  | 'window'
  | 'window.setBackground'
  | 'window.setZoom'
  | 'window.setNativeTheme'

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

AppearanceHostContractWindowCallType#

A window call the backend saw.

TypeScript
type AppearanceHostContractWindowCall =
  | { color: string; kind: 'background' }
  | { factor: number; kind: 'zoom' }
  | { kind: 'nativeTheme'; mode: AppearanceMode }

ui/src/appearance/testing/contract.ts:36

AppearanceHostHarnessFactoryType#

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

TypeScript
type AppearanceHostHarnessFactory = (backend: AppearanceHostContractBackend) => AppearanceHostHarness | Promise<AppearanceHostHarness>

ui/src/appearance/testing/contract.ts:74