Skip to content

zidane-ui/views/testing

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

Functions#

createFixtureViewsHostFunction#

zidane-ui/views/testing: a ViewsHost that runs in memory (createFixtureViewsHost), for docs, demos, galleries and an app's own tests. Not for production hosts.

TypeScript
function createFixtureViewsHost(options?: FixtureViewsOptions): FixtureViewsHost
Parameters
NameTypeDefaultDescription
options?FixtureViewsOptions{}

The stored views, and whether refresh is offered.

ui/src/views/testing/fixture-host.ts:38

createMemorySavedViewsFunction#

Saved views in memory over a backend's stored views. The scope is always ""; the key is made from the view's title.

TypeScript
function createMemorySavedViews(
  viewOf: (sessionId: string, id: string) => StoredView | undefined,
): MemorySavedViews
Parameters
NameTypeDescription
viewOf(sessionId: string, id: string) => StoredView | undefined

The stored view, or undefined.

ui/src/views/testing/saved-memory.ts:31

Interfaces#

FixtureViewsControlInterface#

Changes the stored views from outside, as the host would.

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

Stores a view (new or replacing) and tells the readers, as views:changed does.

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

The stored view, or undefined.

ui/src/views/testing/fixture-host.ts:21

FixtureViewsOptionsInterface#

Options of createFixtureViewsHost.

TypeScript
interface FixtureViewsOptions
FixtureViewsOptions properties
NameTypeDescription
refresh?boolean

The host can refresh: a refresh marks the view and its sources refreshed now and keeps its tree. false: it answers unsupported. Default: true.

saved?boolean

The host saves views (docs/VIEWS-SAVED.md), in memory. Default: false.

views?readonly StoredView[]

The stored views, of any session. Default: none.

ui/src/views/testing/fixture-host.ts:11

MemorySavedViewsInterface#

The saved members of a views backend, held in memory.

TypeScript
interface MemorySavedViews
MemorySavedViews properties
NameTypeDescription
get(ref: { key: string; kind: 'saved'; scope: string; version?: number }) => SavedViewRecord | null

One version (no version: the latest), or null.

list(scope?: string) => SavedViewMeta[]

The saved views, newest first.

remove(scope: string, key: string) => boolean

Deletes a saved view. false: there was none.

save(sessionId: string, id: string) => SavedViewMeta | null

Saves view (sessionId, id): a new version, unless the latest is that view unchanged. null: no such view.

unsave(sessionId: string, id: string) => boolean

Deletes the saved view that view saved. false: it saved none.

versions(scope: string, key: string) => SavedViewVersion[]

The versions of a saved view, oldest first.

ui/src/views/testing/saved-memory.ts:10

Types#

FixtureViewsHostType#

An in-memory ViewsHost and its control.

TypeScript
type FixtureViewsHost = ViewsHost & { control: FixtureViewsControl }

ui/src/views/testing/fixture-host.ts:29