Skip to content

Commit

Permalink
fix: 🐛 refactor writeFileSync tests to be compatible w/ `strictNull…
Browse files Browse the repository at this point in the history
…Checks`
  • Loading branch information
G-Rath committed Jul 13, 2019
1 parent 62b5a52 commit 4b7f164
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions 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])', () => {
Expand All @@ -7,15 +7,15 @@ 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);
});
it('Write to file by file descriptor', () => {
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);
});
Expand All @@ -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();
Expand Down

0 comments on commit 4b7f164

Please sign in to comment.