Skip to content

zidane-ui/palette/testing/contract

import { … } from 'zidane-ui/palette/testing/contract'ui/src/palette/testing/contract.ts

Functions#

describePaletteHostContractFunction#

Declares the shared PaletteHost suite for one implementation.

TypeScript
function describePaletteHostContract(
  name: string,
  makeHarness: PaletteHostHarnessFactory,
  capabilities: readonly PaletteHostCapability[],
): void
Parameters
NameTypeDescription
namestring

The implementation's name, shown in the suite title.

makeHarnessPaletteHostHarnessFactory

Builds a fresh host over a backend that holds what it is given, once per test.

capabilitiesreadonly PaletteHostCapability[]

The optional members the host offers. Every other optional member must be undefined.

ui/src/palette/testing/contract.ts:116

Interfaces#

PaletteHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface PaletteHostContractBackend
PaletteHostContractBackend properties
NameTypeDescription
commandsreadonly PaletteCommand[]

The / commands for cwd.

conversationsReadonly<Record<string, string>>

Each session's conversation text, by session id (what a content search scans).

cwdstring

The project folder (the commands' cwd, the files' root).

extensionFailing{ itemId: string; message: string }

What running an extension item does: a notice with its id, or a failure with this message for extensionFailing.

extensionItemsreadonly PaletteItem[]

Extension items for cwd (each source is its provider's id).

filesreadonly string[]

The files under cwd, relative, /-separated.

sessionIdstring

A session in that folder (hosts that list a session's workspace list it through this one).

settingsPartial<Settings>

The settings in effect. Writes land here.

ui/src/palette/testing/contract.ts:44

PaletteHostHarnessInterface#

A host built over a backend, and what the suite drives on it.

TypeScript
interface PaletteHostHarness
PaletteHostHarness properties
NameTypeDescription
hostPaletteHost

The host under test.

changeExtensions?() => void

Has the backend announce that the extension items changed (needed for extensions.subscribe).

dispose?() => void

Closes connections and timers after each test.

ui/src/palette/testing/contract.ts:64

Types#

PaletteHostCapabilityType#

An optional PaletteHost member, by its path.

TypeScript
type PaletteHostCapability =
  | 'listCommands'
  | 'listFiles'
  | 'extensions'
  | 'extensions.subscribe'
  | 'settings'
  | 'setSettings'
  | 'recents'
  | 'searchConversations'

ui/src/palette/testing/contract.ts:22

PaletteHostHarnessFactoryType#

Builds a fresh host (and its backend) for one test.

TypeScript
type PaletteHostHarnessFactory = (backend: PaletteHostContractBackend) => PaletteHostHarness | Promise<PaletteHostHarness>

ui/src/palette/testing/contract.ts:74