Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 45x 45x 4x 10x 10x 45x 312x 312x 45x 64x 45x 17x 17x 17x 45x 45x 45x | import { createFsFromVolume, Volume } from '..';
import { Link, Node } from '../node';
// Turn the done callback into an incremental one that will only fire after being called
// `times` times, failing with the first reported error if such exists.
// Useful for testing callback-style functions with several different fixtures without
// having to clutter the test suite with a multitude of individual tests (like it.each would).
export const multitest = (_done: (err?: Error) => void, times: number) => {
let err;
return function done(_err?: Error) {
err ??= _err;
if (!--times) _done(_err);
};
};
export const create = (json: { [s: string]: string } = { '/foo': 'bar' }) => {
const vol = Volume.fromJSON(json);
return vol;
};
export const createFs = (json?) => {
return createFsFromVolume(create(json));
};
export const tryGetChild = (link: Link, name: string): Link => {
const child = link.getChild(name);
Iif (!child) {
throw new Error(`expected link to have a child named "${name}"`);
}
return child;
};
export const tryGetChildNode = (link: Link, name: string): Node => tryGetChild(link, name).getNode();
const nodeMajorVersion = +process.version.split('.')[0].slice(1);
/**
* The `File` global is available only starting in Node v20. Hence we run the
* tests only in those versions.
*/
export const onlyOnNode20 = nodeMajorVersion >= 20 ? describe : describe.skip;
|