All files / src/__tests__ util.ts

94.73% Statements 18/19
50% Branches 2/4
100% Functions 4/4
92.85% Lines 13/14

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 3233x     33x 74x 74x     33x 7x     33x 17x   17x       17x     33x   33x           33x  
import { createFsFromVolume, Volume } from '..';
import { Link, Node } from '../node';
 
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;