From 9de64744e3d86227a470054be47870f1b1da8ed1 Mon Sep 17 00:00:00 2001 From: tcme <546900+thisconnect@users.noreply.github.com> Date: Sat, 1 Jun 2019 19:08:41 +0200 Subject: [PATCH] Test ENOTDIR|EEXIST error when parent is a file (#15) --- test/async.js | 7 +++++++ test/sync.js | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/test/async.js b/test/async.js index 56399f6..36be617 100644 --- a/test/async.js +++ b/test/async.js @@ -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 diff --git a/test/sync.js b/test/sync.js index 2787d8d..689076d 100644 --- a/test/sync.js +++ b/test/sync.js @@ -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