-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 throw when creating root directory
closes #325
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`mkdirSync throws when creating root directory 1`] = `"EISDIR: illegal operation on a directory, mkdir"`; | ||
|
||
exports[`mkdirSync throws when re-creating existing directory 1`] = `"EEXIST: file already exists, mkdir '/new-dir'"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { create } from '../util'; | ||
|
||
describe('mkdirSync', () => { | ||
it('can create a directory', () => { | ||
const vol = create(); | ||
|
||
vol.mkdirSync('/new-dir'); | ||
const stat = vol.statSync('/new-dir'); | ||
|
||
expect(stat.isDirectory()).toBe(true); | ||
}); | ||
|
||
it('root directory is directory', () => { | ||
const vol = create(); | ||
const stat = vol.statSync('/'); | ||
|
||
expect(stat.isDirectory()).toBe(true); | ||
}); | ||
|
||
it('throws when re-creating existing directory', () => { | ||
const vol = create(); | ||
|
||
vol.mkdirSync('/new-dir'); | ||
|
||
let error; | ||
try { | ||
vol.mkdirSync('/new-dir'); | ||
} catch (err) { | ||
error = err; | ||
} | ||
|
||
expect(error).toBeInstanceOf(Error); | ||
expect(error.message).toMatchSnapshot(); | ||
}); | ||
|
||
/** | ||
* See issue #325 | ||
* https://github.com/streamich/memfs/issues/325 | ||
*/ | ||
it('throws when creating root directory', () => { | ||
const vol = create(); | ||
|
||
let error; | ||
try { | ||
vol.mkdirSync('/'); | ||
} catch (err) { | ||
error = err; | ||
} | ||
|
||
expect(error).toBeInstanceOf(Error); | ||
expect(error.message).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters