Skip to content

zidane-ui/appearance/testing

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

Functions#

createFixtureAppearanceHostFunction#

Creates an AppearanceHost held in memory.

TypeScript
function createFixtureAppearanceHost(
  options?: FixtureAppearanceOptions,
): FixtureAppearanceHost
Parameters
NameTypeDefaultDescription
options?FixtureAppearanceOptions{}

Stored preferences, extra themes, and which optional members to offer.

ui/src/appearance/headless/fixture-host.ts:63

memoryStorageFunction#

A Storage double over a Map.

TypeScript
function memoryStorage(): AppearanceStorage & { removeItem(key: string): void }
AppearanceStorage & { removeItem(key: string): void }

ui/src/appearance/headless/fixture-host.ts:49

Interfaces#

FixtureAppearanceControlInterface#

What the fixture recorded, and a way to change it from outside.

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

The last snapshot written, or null.

stored() => string | null

The stored blob, as the storage holds it.

storeExternally(raw: string | null) => void

Another window stored this blob (null clears it): the host adopts it and tells subscribers.

windowCalls() => readonly FixtureWindowCall[]

Every window call, in order.

ui/src/appearance/headless/fixture-host.ts:34

FixtureAppearanceOptionsInterface#

Options of createFixtureAppearanceHost.

TypeScript
interface FixtureAppearanceOptions
FixtureAppearanceOptions properties
NameTypeDescription
boot?boolean

Record the snapshot (boot). Default: true.

prefs?Partial<AppearanceState>

Preferences already stored (merged over the defaults). Default: none, a first run.

themes?Readonly<Record<string, readonly Theme[]>>

The extra themes per folder. Default: none (themes is left out).

window?boolean

Record window calls (window). Default: true.

ui/src/appearance/headless/fixture-host.ts:16

Types#

FixtureAppearanceHostType#

An in-memory AppearanceHost and its control.

TypeScript
type FixtureAppearanceHost = AppearanceHost & { control: FixtureAppearanceControl }

ui/src/appearance/headless/fixture-host.ts:46

FixtureWindowCallType#

A window call the fixture recorded.

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

ui/src/appearance/headless/fixture-host.ts:28