-
Notifications
You must be signed in to change notification settings - Fork 0
/
filetree.spec.js
54 lines (38 loc) · 1.28 KB
/
filetree.spec.js
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
var expect = require('chai').expect,
fs = require('fs-extra'),
path = require('path'),
sinon = require('sinon'),
filetree = require('./filetree.js'),
logBuffer = [];
describe('filetree', function () {
it('should throw when passed an invalid path', function () {
var stub,
filePath = '/tmp/path/to/invalid/folder';
stub = sinon.stub(console, 'log');
expect(function () {
filetree({path: filePath});
}).to.throw(Error);
stub.restore();
});
it('should throw when passed a valid file path', function () {
var stub,
filePath = '/tmp/path/to/valid/file';
fs.mkdirsSync(path.dirname(filePath));
fs.closeSync(fs.openSync(filePath, 'w'));
stub = sinon.stub(console, 'log');
expect(function () {
filetree({path: filePath});
}).to.throw(Error);
stub.restore();
});
it('should not throw when passed a valid directory path', function () {
var stub,
filePath = '/tmp/path/to/valid/folder';
fs.mkdirsSync(filePath);
stub = sinon.stub(console, 'log');
expect(function () {
filetree({path: filePath});
}).to.not.throw(Error);
stub.restore();
});
});