FakeFileSaver
A recording FileSaver.
This is a class exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { FakeFileSaver } from "@mapcairn/core";
class FakeFileSaver implements FileSaver
Description
How to script it: it succeeds by default. failWith(reason) makes every
later save resolve to { ok: false, reason } and succeed() restores
success. saved holds the files that were saved and attempts every file
offered. It never rejects.
Properties
attempts
readonly attempts: SavedFile[];
Every file offered, in order, whether it was saved or not.
saved
readonly saved: SavedFile[];
The files that were saved, in order.
Methods
failWith
failWith(reason: FileSaveFailureReason): void;
Makes every later save fail for this reason.
reason(FileSaveFailureReason)
save
save(file: SavedFile): Promise<FileSaveResult>;
Records the file in attempts, and in saved too unless a failure is scripted. It resolves to a result and never rejects.
file(SavedFile)
succeed
succeed(): void;
Makes every later save succeed.