diff --git a/src/__tests__/volume/writeFileSync.test.ts b/src/__tests__/volume/writeFileSync.test.ts index 3fe156f6..fc089668 100644 --- a/src/__tests__/volume/writeFileSync.test.ts +++ b/src/__tests__/volume/writeFileSync.test.ts @@ -1,4 +1,4 @@ -import { create } from '../util'; +import { create, tryGetChildNode } from '../util'; import { Node } from '../../node'; describe('writeFileSync(path, data[, options])', () => { @@ -7,7 +7,7 @@ describe('writeFileSync(path, data[, options])', () => { const vol = create(); vol.writeFileSync('/writeFileSync.txt', data); - const node = vol.root.getChild('writeFileSync.txt').getNode(); + const node = tryGetChildNode(vol.root, 'writeFileSync.txt'); expect(node).toBeInstanceOf(Node); expect(node.getString()).toBe(data); }); @@ -15,7 +15,7 @@ describe('writeFileSync(path, data[, options])', () => { const vol = create(); const fd = vol.openSync('/writeByFd.txt', 'w'); vol.writeFileSync(fd, data); - const node = vol.root.getChild('writeByFd.txt').getNode(); + const node = tryGetChildNode(vol.root, 'writeByFd.txt'); expect(node).toBeInstanceOf(Node); expect(node.getString()).toBe(data); }); @@ -32,18 +32,8 @@ describe('writeFileSync(path, data[, options])', () => { vol.writeFileSync(fd2, '456'); - expect( - vol.root - .getChild('1.txt') - .getNode() - .getString(), - ).toBe('123'); - expect( - vol.root - .getChild('2.txt') - .getNode() - .getString(), - ).toBe('456'); + expect(tryGetChildNode(vol.root, '1.txt').getString()).toBe('123'); + expect(tryGetChildNode(vol.root, '2.txt').getString()).toBe('456'); }); it('Write at relative path that does not exist throws correct error', () => { const vol = create();