From 4b7f1643cc312f12fb2dcc7aa3b1b3fc08ff007f Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 13 Jul 2019 12:25:42 +1200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20refactor=20`writeFileSync?= =?UTF-8?q?`=20tests=20to=20be=20compatible=20w/=20`strictNullChecks`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/volume/writeFileSync.test.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) 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();