forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-test.ts
More file actions
36 lines (32 loc) · 1.05 KB
/
error-test.ts
File metadata and controls
36 lines (32 loc) · 1.05 KB
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
/**
* Ensures that OverlayFS throws initialization errors.
*/
import fs from '../../../../src/core/node_fs';
import assert from '../../../harness/wrapped-assert';
import OverlayFS from '../../../../src/backend/OverlayFS';
export default function() {
var rootFS = fs.getRootFS(),
fses = (<OverlayFS> rootFS).getOverlayedFileSystems(),
// XXX: Make these proper API calls.
readable = fses.readable,
writable = fses.writable;
fs.initialize(new OverlayFS(writable, readable));
var err: NodeJS.ErrnoException = null;
try {
fs.readdirSync('/');
} catch (e) {
err = e;
}
assert(err !== null, 'OverlayFS should throw an exception if it is not initialized.');
try {
fs.readdir('/', function(err) {
assert(Boolean(err), 'OverlayFS should pass an exception to its callback if it is not initialized.');
});
} catch (e) {
assert(false, 'OverlayFS should never *throw* an exception on an asynchronous API call.');
}
process.on('exit', function() {
// Restore saved file system.
fs.initialize(rootFS);
});
};