Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: 🐛 refactor volume tests to use tryGetChild
  • Loading branch information
G-Rath committed Jul 13, 2019
1 parent 34acaac commit 5a6624f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/volume.test.ts
Expand Up @@ -4,7 +4,7 @@ import Stats from '../Stats';
import Dirent from '../Dirent';
import { Volume, filenameToSteps, StatWatcher } from '../volume';
import hasBigInt from './hasBigInt';
import { tryGetChildNode } from './util';
import { tryGetChild, tryGetChildNode } from './util';

describe('volume', () => {
describe('filenameToSteps(filename): string[]', () => {
Expand Down Expand Up @@ -873,28 +873,28 @@ describe('volume', () => {
it('Create dir at root', () => {
const vol = new Volume();
vol.mkdirSync('/test');
const child = vol.root.getChild('test');
const child = tryGetChild(vol.root, 'test');
expect(child).toBeInstanceOf(Link);
expect(child.getNode().isDirectory()).toBe(true);
});
it('Create 2 levels deep folders', () => {
const vol = new Volume();
vol.mkdirSync('/dir1');
vol.mkdirSync('/dir1/dir2');
const dir1 = vol.root.getChild('dir1');
const dir1 = tryGetChild(vol.root, 'dir1');
expect(dir1).toBeInstanceOf(Link);
expect(dir1.getNode().isDirectory()).toBe(true);
const dir2 = dir1.getChild('dir2');
const dir2 = tryGetChild(dir1, 'dir2');
expect(dir2).toBeInstanceOf(Link);
expect(dir2.getNode().isDirectory()).toBe(true);
expect(dir2.getPath()).toBe('/dir1/dir2');
});
it('Create /dir1/dir2/dir3 recursively', () => {
const vol = new Volume();
vol.mkdirSync('/dir1/dir2/dir3', { recursive: true });
const dir1 = vol.root.getChild('dir1');
const dir2 = dir1.getChild('dir2');
const dir3 = dir2.getChild('dir3');
const dir1 = tryGetChild(vol.root, 'dir1');
const dir2 = tryGetChild(dir1, 'dir2');
const dir3 = tryGetChild(dir2, 'dir3');
expect(dir1).toBeInstanceOf(Link);
expect(dir2).toBeInstanceOf(Link);
expect(dir3).toBeInstanceOf(Link);
Expand Down

0 comments on commit 5a6624f

Please sign in to comment.