Skip to content

zidane-ui/files/testing/contract

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

Functions#

describeFilesHostContractFunction#

Declares the shared FilesHost suite for one implementation.

TypeScript
function describeFilesHostContract(
  name: string,
  makeHarness: FilesHostHarnessFactory,
  capabilities: readonly FilesHostCapability[],
): void
Parameters
NameTypeDescription
namestring

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

makeHarnessFilesHostHarnessFactory

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

capabilitiesreadonly FilesHostCapability[]

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

ui/src/files/testing/contract.ts:112

Interfaces#

FilesHostContractBackendInterface#

What the backend behind the host holds.

TypeScript
interface FilesHostContractBackend
FilesHostContractBackend properties
NameTypeDescription
cwdstring

The folder (absolute).

diffstring

Its working tree against HEAD, as a unified patch.

filesReadonly<Record<string, string>>

Its text files, by path relative to it.

statusreadonly GitStatusEntry[]

Its git status.

ui/src/files/testing/contract.ts:52

FilesHostContractControlInterface#

Reads the backend and changes it from outside.

TypeScript
interface FilesHostContractControl
FilesHostContractControl properties
NameTypeDescription
edit(path: string, text: string) => void

Another writer changed a file (its version moves).

file(path: string) => string | undefined

A file's text in the backend now, or undefined.

touch?() => void

The folder may have changed (a tool result in it): watchers hear it. Required with watch.

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

FilesHostHarnessInterface#

A host built over a backend, the backend's control, and how to tear them down.

TypeScript
interface FilesHostHarness
FilesHostHarness properties
NameTypeDescription
controlFilesHostContractControl

Reads and changes the backend.

hostFilesHost

The host under test.

dispose?() => void

Closes listeners after each test.

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

Types#

FilesHostCapabilityType#

An optional FilesHost member.

TypeScript
type FilesHostCapability =
  | 'list'
  | 'read'
  | 'write'
  | 'entries'
  | 'search'
  | 'gitStatus'
  | 'workingTreeDiff'
  | 'watch'
  | 'editorPrefs'
  | 'diagnostics'
  | 'lsp'
  | 'system'
  | 'mediaUrl'

ui/src/files/testing/contract.ts:20

FilesHostHarnessFactoryType#

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

TypeScript
type FilesHostHarnessFactory = (backend: FilesHostContractBackend) => FilesHostHarness | Promise<FilesHostHarness>

ui/src/files/testing/contract.ts:84