-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
67 lines (59 loc) · 2.38 KB
/
test.js
File metadata and controls
67 lines (59 loc) · 2.38 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
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
67
const addon = require('.');
const should = require('should');
describe('Addon', () => {
it('should export statvfs symbol', () => {
should.exist(addon.statvfs);
});
});
describe('statvfs', () => {
it('should return a promise', () => {
return addon.statvfs(__filename).should.be.fulfilled();
});
it('should succeed for existing paths', () => {
return addon.statvfs('/')
.then((res) => {
res.should.be.an.Object();
res.should.have.properties('type', 'bsize', 'blocks', 'bfree', 'bavail', 'files', 'ffree');
res.bavail.should.be.lessThanOrEqual(res.bfree);
res.bfree.should.be.lessThanOrEqual(res.blocks);
res.bsize.should.be.greaterThanOrEqual(0);
res.ffree.should.be.lessThanOrEqual(res.files);
});
});
it('should accept Buffers', () => {
return addon.statvfs(Buffer.from('/'))
.then((res) => {
res.should.be.an.Object();
res.should.have.properties('type', 'bsize', 'blocks', 'bfree', 'bavail', 'files', 'ffree');
});
});
it('should fail for non-existing paths', () => {
const path = __filename + '/';
return addon.statvfs(path).should.be.rejected()
.then((e) => {
e.should.be.instanceof(Error);
e.should.have.properties('code', 'errno', 'path', 'message');
e.path.should.be.equal(path);
});
});
});
describe('statvfsSync', () => {
it('should succeed for existing paths', () => {
const res = addon.statvfsSync('/')
res.should.be.an.Object();
res.should.have.properties('type', 'bsize', 'blocks', 'bfree', 'bavail', 'files', 'ffree');
res.bavail.should.be.lessThanOrEqual(res.bfree);
res.bfree.should.be.lessThanOrEqual(res.blocks);
res.bsize.should.be.greaterThanOrEqual(0);
res.ffree.should.be.lessThanOrEqual(res.files);
});
it('should accept Buffers', () => {
const res = addon.statvfsSync(Buffer.from('/'))
res.should.be.an.Object();
res.should.have.properties('type', 'bsize', 'blocks', 'bfree', 'bavail', 'files', 'ffree');
});
it('should fail for non-existing paths', () => {
const path = __filename + '/';
(() => addon.statvfsSync(path)).should.throw(Error);
});
});