FakeFileOpener
A scripted FileOpener that plays the person at the picker.
This is a class exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { FakeFileOpener } from "@mapcairn/core";
class FakeFileOpener implements FileOpener
Description
How to script it: open waits, as a real picker does, until choose(file)
or cancel() settles it. failWith("unsupported") makes later opens
reject at once, failWith("unreadable") makes a chosen file unreadable,
and succeed() clears either. A chosen file's size is its length in
characters. opens records the options of every call and waiting says
whether a picker is open. It rejects only with FileOpenError.
Properties
opens
readonly opens: FileOpenOptions[];
The options of every open call, in order.
waiting
readonly get waiting(): boolean;
Whether a picker is open and waiting for the person.
Methods
cancel
cancel(): void;
The person closes the open picker without choosing.
choose
choose(file: OpenedFile): void;
The person chooses file in the open picker. Does nothing when none is open.
file(OpenedFile)
failWith
failWith(kind: FakeFileOpenFailure): void;
Makes later opens fail this way.
kind(FakeFileOpenFailure)
open
open(options: FileOpenOptions): Promise<OpenedFile>;
Waits, as a real picker does, until choose or cancel settles it. It rejects at once when failWith("unsupported") is scripted.
options(FileOpenOptions)
succeed
succeed(): void;
Makes later opens work again.