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