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.
function createFixtureViewsHost(options?: FixtureViewsOptions): FixtureViewsHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixtureViewsOptions | {} | The stored views, and whether refresh is offered. |
Returns
createMemorySavedViewsFunction#
Saved views in memory over a backend's stored views. The scope is always
""; the key is made from the view's title.
function createMemorySavedViews(
viewOf: (sessionId: string, id: string) => StoredView | undefined,
): MemorySavedViewsParameters
| Name | Type | Description |
|---|---|---|
| viewOf | (sessionId: string, id: string) => StoredView | undefined | The stored view, or |
Returns
Interfaces#
FixtureViewsControlInterface#
Changes the stored views from outside, as the host would.
interface FixtureViewsControlProperties
| Name | Type | Description |
|---|---|---|
| add | (view: StoredView) => void | Stores a view (new or replacing) and tells the readers, as |
| view | (sessionId: string, id: string) => StoredView | undefined | The stored view, or |
FixtureViewsOptionsInterface#
Options of createFixtureViewsHost.
interface FixtureViewsOptionsProperties
| Name | Type | Description |
|---|---|---|
| refresh? | boolean | The host can refresh: a refresh marks the view and its sources refreshed now and keeps its tree. |
| 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. |
MemorySavedViewsInterface#
The saved members of a views backend, held in memory.
interface MemorySavedViewsProperties
| Name | Type | Description |
|---|---|---|
| get | (ref: { key: string; kind: 'saved'; scope: string; version?: number }) => SavedViewRecord | null | One version (no version: the latest), or |
| list | (scope?: string) => SavedViewMeta[] | The saved views, newest first. |
| remove | (scope: string, key: string) => boolean | Deletes a saved view. |
| save | (sessionId: string, id: string) => SavedViewMeta | null | Saves view |
| unsave | (sessionId: string, id: string) => boolean | Deletes the saved view that view saved. |
| versions | (scope: string, key: string) => SavedViewVersion[] | The versions of a saved view, oldest first. |
Types#
FixtureViewsHostType#
An in-memory ViewsHost and its control.
type FixtureViewsHost = ViewsHost & { control: FixtureViewsControl }