Skip to content

zidane-ui/files/testing

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

Functions#

createFixtureFilesHostFunction#

An in-memory FilesHost: list, read, write (version-guarded), search, git status, the working-tree diff, watch and editor preferences. No diagnostics, language servers, system actions or media addresses.

TypeScript
function createFixtureFilesHost(options?: FixtureFilesHostOptions): FixtureFilesHost
Parameters
NameTypeDefaultDescription
options?FixtureFilesHostOptions{}

The files, the git status and the patches it starts with.

ui/src/files/headless/fixture-host.ts:164

memoryEntryPortFunction#

An EntryPort over the fixture's memory: files by path, made folders, a version clock. Also a fake backend's (tests).

TypeScript
function memoryEntryPort(
  files: Map<string, { text: string; version: number }>,
  dirs: Set<string>,
  tick: () => number,
): EntryPort
Parameters
NameTypeDescription
filesMap<string, { text: string; version: number }>

The files, by path, with their text and version.

dirsSet<string>

The folders made with no file in them yet.

tick() => number

The next version number.

EntryPort

ui/src/files/headless/fixture-host.ts:82

Constants#

DEMO_FILESConstant#

The demo folder's files, its git status and its working-tree patches.

TypeScript
const DEMO_FILES: Required<FixtureFilesHostOptions>

ui/src/files/testing/demo.ts:8

Interfaces#

FixtureFilesControlInterface#

Changes the fixture from outside.

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

Another writer changed (or created) a file: its version moves.

emptyDirs() => string[]

The empty folders now.

file(path: string) => string | undefined

A file's text now, or undefined.

setDiff(diff: string) => void

Sets the working-tree patch.

setStatus(status: readonly GitStatusEntry[]) => void

Sets the git status.

touch(why?: FolderChange) => void

The folder may have changed: every watcher hears why.

ui/src/files/headless/fixture-host.ts:38

FixtureFilesHostOptionsInterface#

Options of createFixtureFilesHost.

TypeScript
interface FixtureFilesHostOptions
FixtureFilesHostOptions properties
NameTypeDescription
diff?string

Its working tree against HEAD, as a unified patch. Default: empty.

fileDiffs?Readonly<Record<string, string>>

Per-file patches for workingTreeDiff({ path }). Default: none (an empty patch).

files?Readonly<Record<string, string>>

The folder's text files, by path relative to it.

status?readonly GitStatusEntry[]

Its git status. Default: none.

ui/src/files/headless/fixture-host.ts:26

Types#

FixtureFilesHostType#

The fixture host, with its FixtureFilesControl.

TypeScript
type FixtureFilesHost = FilesHost & { control: FixtureFilesControl }

ui/src/files/headless/fixture-host.ts:54