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.
function describeAppearanceHostContract(
name: string,
makeHarness: AppearanceHostHarnessFactory,
capabilities: readonly AppearanceHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | AppearanceHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly AppearanceHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
AppearanceHostContractBackendInterface#
What the backend behind the host holds.
interface AppearanceHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| stored | string | null | The stored preferences blob, or |
| themes | Readonly<Record<string, readonly Theme[]>> | The extra themes per folder (a folder missing here has none). |
AppearanceHostContractControlInterface#
Reads the backend and changes it from outside.
interface AppearanceHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| boot? | () => BootSnapshot | null | The snapshot the backend holds, or |
| 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 ( |
| windowCalls? | () => readonly AppearanceHostContractWindowCall[] | The window calls the backend saw, in order (hosts with |
AppearanceHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface AppearanceHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | AppearanceHostContractControl | Reads and changes the backend. |
| host | AppearanceHost | The host under test. |
| dispose? | () => void | Closes listeners after each test. |
Types#
AppearanceHostCapabilityType#
An optional AppearanceHost member, by its path.
type AppearanceHostCapability =
| 'themes'
| 'boot'
| 'window'
| 'window.setBackground'
| 'window.setZoom'
| 'window.setNativeTheme'AppearanceHostContractWindowCallType#
A window call the backend saw.
type AppearanceHostContractWindowCall =
| { color: string; kind: 'background' }
| { factor: number; kind: 'zoom' }
| { kind: 'nativeTheme'; mode: AppearanceMode }AppearanceHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type AppearanceHostHarnessFactory = (backend: AppearanceHostContractBackend) => AppearanceHostHarness | Promise<AppearanceHostHarness>