Skip to content

Commit

Permalink
Test ENOTDIR|EEXIST error when parent is a file (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisconnect authored and sindresorhus committed Jun 1, 2019
1 parent 49b26bd commit 9de6474
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ test('file exits', async t => {
await t.throwsAsync(makeDir(fp), {code: 'EEXIST'});
});

test('parent dir is file', async t => {
const fp = tempy.file();
fs.writeFileSync(fp, '');
const error = await t.throwsAsync(makeDir(fp + '/sub/dir'));
t.regex(error.code, /ENOTDIR|EEXIST/);
});

test('root dir', async t => {
if (process.platform === 'win32') {
// Do not assume that `C:` is current drive
Expand Down
9 changes: 9 additions & 0 deletions test/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ test('file exits', t => {
}, {code: 'EEXIST'});
});

test('parent dir is file', t => {
const fp = tempy.file();
fs.writeFileSync(fp, '');
const error = t.throws(() => {
makeDir.sync(fp + '/sub/dir');
});
t.regex(error.code, /ENOTDIR|EEXIST/);
});

test('root dir', t => {
if (process.platform === 'win32') {
// Do not assume that `C:` is current drive
Expand Down

0 comments on commit 9de6474

Please sign in to comment.