forked from streamich/memfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkdirSync.test.ts
66 lines (51 loc) · 1.37 KB
/
mkdirSync.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { create } from '../util';
import type Stats from '../../Stats';
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();
});
/**
* See issue #938
* https://github.com/streamich/memfs/issues/938
*/
it('can create a directory with name "__proto__"', () => {
const vol = create();
vol.mkdirSync('/__proto__');
expect(vol.statSync('/__proto__').isDirectory()).toBe(true);
});
});