Skip to content

Commit 27627f2

Browse files
authored
Merge pull request #1264 from streamich/test-fixes
test: 💍 harden test to work on Windows
2 parents 3ed738f + 8a93685 commit 27627f2

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

packages/fs-node/src/__tests__/volume.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,9 +1637,25 @@ describe('volume', () => {
16371637
});
16381638

16391639
it('suppresses only ENOENT; other errors still throw', () => {
1640-
const vol = Volume.fromJSON({ '/file.txt': 'x' });
1640+
const vol = Volume.fromJSON({ '/dir/file.txt': 'x' });
1641+
vol.chmodSync('/dir', 0);
1642+
expect(() => vol.watch('/dir/file.txt', { throwIfNoEntry: false })).toThrow(/EACCES/);
1643+
});
1644+
1645+
it('throws ENOTDIR for traversal through a file on POSIX', () => {
1646+
const vol = Volume.fromJSON({ '/file.txt': 'x' }, undefined, {
1647+
process: { ...process, platform: 'linux' },
1648+
});
16411649
expect(() => vol.watch('/file.txt/sub', { throwIfNoEntry: false })).toThrow(/ENOTDIR/);
16421650
});
1651+
1652+
it('suppresses the ENOENT reported for traversal through a file on Windows', () => {
1653+
const vol = Volume.fromJSON({ '/file.txt': 'x' }, undefined, {
1654+
process: { ...process, platform: 'win32' },
1655+
});
1656+
const watcher = vol.watch('/file.txt/sub', { throwIfNoEntry: false });
1657+
watcher.close();
1658+
});
16431659
});
16441660

16451661
describe('ignore option', () => {

0 commit comments

Comments
 (0)