-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-vfs.ts
64 lines (54 loc) · 1.46 KB
/
test-vfs.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
import { getContents, getFullContents, getItem, insertPlans, mkFs } from '../src/fs/fs';
import { SpecialId } from '../src/fs/initial-fs';
import { testFile } from "./testing-utils";
const jestConsole = console;
describe('virtual filesystem', () => {
test('should work correctly', () => {
const fs = (() => {
let fs = mkFs();
[fs,] = insertPlans(fs, SpecialId.root, [
{ t: 'virtual', id: 'vroot' },
{
t: 'dir', name: 'dir', forceId: 'dir', contents: [
testFile('foo_a'),
]
}
]);
return fs;
})();
expect(getContents(fs, '_gen_vroot').length > 0).toBe(true);
expect(getFullContents(fs, '_gen_vroot').map(x => x.name))
.toEqual([
"gbar",
"zdbaz",
"sfoo",
"gbaz",
"jgbaz",
'\x81\x95\x83\x9D\x95'
]);
expect(getFullContents(fs, '_root').map(x => x.name))
.toEqual([
'virtual',
'dir',
]);
});
test('should permit virtual filesystem occurring not at root', () => {
const fs = (() => {
let fs = mkFs();
[fs,] = insertPlans(fs, SpecialId.root, [
{
t: 'dir', name: 'dir', forceId: 'dir', contents: [
{ t: 'virtual', id: 'vroot' },
testFile('foo_a'),
]
}
]);
return fs;
})();
expect(getFullContents(fs, 'dir').map(x => x.name))
.toEqual([
'virtual',
'foo_a',
]);
});
});