zidane-ui/ palette/ testing
import { … } from 'zidane-ui/palette/testing'ui/src/palette/testing/index.ts
Functions#
createFixturePaletteHostFunction#
Creates a PaletteHost held in memory.
function createFixturePaletteHost(options?: FixturePaletteOptions): FixturePaletteHostParameters
| Name | Type | Default | Description |
|---|---|---|---|
| options? | FixturePaletteOptions | {} | Its commands, files, extension items, settings and recents. |
Returns
Constants#
DEMO_PALETTE_COMMANDSConstant#
Demo / commands.
const DEMO_PALETTE_COMMANDS: readonly PaletteCommand[]DEMO_PALETTE_CONVERSATIONSConstant#
Demo conversation text, by session id, for the content search.
const DEMO_PALETTE_CONVERSATIONS: Readonly<Record<string, string>>DEMO_PALETTE_EXTENSION_ITEMSConstant#
A demo extension item (its source is its provider's id).
const DEMO_PALETTE_EXTENSION_ITEMS: readonly PaletteItem[]DEMO_PALETTE_FILESConstant#
Demo project files, relative to the project root.
const DEMO_PALETTE_FILES: readonly string[]Interfaces#
FixturePaletteHostInterface#
The PaletteHost createFixturePaletteHost returns, plus a way to change its extension items.
interface FixturePaletteHost extends PaletteHostProperties
| Name | Type | Description |
|---|---|---|
extensions?from PaletteHost | PaletteExtensions | Extension-contributed items. Absent: no extensions source. |
recents?from PaletteHost | PaletteRecents | Persistent recents. Absent: recents last as long as the page. |
settings?from PaletteHost | Readable<Partial<Settings>> | The settings in effect, read when the palette lists its rows. Absent: no settings rows. |
listCommands?from PaletteHost | (query: PaletteCommandQuery) => Promise<readonly PaletteCommand[]> | The |
listFiles?from PaletteHost | (query: PaletteFileQuery) => Promise<readonly PaletteFileEntry[]> | The project's files (without gitignored ones). Absent: no files source. |
searchConversations?from PaletteHost | (query: PaletteConversationQuery) => Promise<readonly PaletteConversationHit[]> | Content matches inside conversations, best first; a newer call may cancel an older scan (it then resolves with whatever it has, or rejects). Absent: no "In conversations" group. |
| setExtensionItems | (items: readonly PaletteItem[]) => void | Replaces the extension items and tells |
setSettings?from PaletteHost | (patch: Partial<Settings>) => Promise<void> | Applies a settings patch. Absent: settings rows are not offered. |
FixturePaletteOptionsInterface#
Options of createFixturePaletteHost. Each list defaults to the demo data.
interface FixturePaletteOptionsProperties
| Name | Type | Description |
|---|---|---|
| commands? | false | readonly PaletteCommand[] | The |
| conversations? | false | Readonly<Record<string, string>> | Conversation text by session id, for the content search. |
| extensionItems? | false | readonly PaletteItem[] | Extension items. |
| files? | false | readonly string[] | File paths relative to any root. |
| onSetSettings? | (patch: Partial<Settings>) => void | Called with each settings patch, after the host applied it. |
| recents? | readonly string[] | The stored recents. Default: none. |
| runExtension? | (sourceId: string, itemId: string) => PaletteExtensionRun | What running an extension item answers. Default: a notice naming it. |
| settings? | false | Partial<Settings> | The settings in effect. |