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.
function describeFilesHostContract(
name: string,
makeHarness: FilesHostHarnessFactory,
capabilities: readonly FilesHostCapability[],
): voidParameters
| Name | Type | Description |
|---|---|---|
| name | string | The implementation's name, shown in the suite title. |
| makeHarness | FilesHostHarnessFactory | Builds a fresh host over a backend that holds what it is given, once per test. |
| capabilities | readonly FilesHostCapability[] | The optional members the host offers. Every other optional member must be undefined. |
Interfaces#
FilesHostContractBackendInterface#
What the backend behind the host holds.
interface FilesHostContractBackendProperties
| Name | Type | Description |
|---|---|---|
| cwd | string | The folder (absolute). |
| diff | string | Its working tree against HEAD, as a unified patch. |
| files | Readonly<Record<string, string>> | Its text files, by path relative to it. |
| status | readonly GitStatusEntry[] | Its git status. |
FilesHostContractControlInterface#
Reads the backend and changes it from outside.
interface FilesHostContractControlProperties
| Name | Type | Description |
|---|---|---|
| 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 |
| touch? | () => void | The folder may have changed (a tool result in it): watchers hear it. Required with |
FilesHostHarnessInterface#
A host built over a backend, the backend's control, and how to tear them down.
interface FilesHostHarnessProperties
| Name | Type | Description |
|---|---|---|
| control | FilesHostContractControl | Reads and changes the backend. |
| host | FilesHost | The host under test. |
| dispose? | () => void | Closes listeners after each test. |
Types#
FilesHostCapabilityType#
An optional FilesHost member.
type FilesHostCapability =
| 'list'
| 'read'
| 'write'
| 'entries'
| 'search'
| 'gitStatus'
| 'workingTreeDiff'
| 'watch'
| 'editorPrefs'
| 'diagnostics'
| 'lsp'
| 'system'
| 'mediaUrl'FilesHostHarnessFactoryType#
Builds a fresh host (and its backend) for one test.
type FilesHostHarnessFactory = (backend: FilesHostContractBackend) => FilesHostHarness | Promise<FilesHostHarness>