forked from sindresorhus/jsftp-mkdirp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (42 loc) · 1.02 KB
/
test.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
'use strict';
var assert = require('assert');
var fs = require('fs');
var JSFtp = require('jsftp');
var Server = require('ftp-test-server');
JSFtp = require('./index')(JSFtp);
var ftp;
var mockServer;
var testDir = '/foo/bar/baz';
before(function (done) {
mockServer = new Server();
mockServer.init({
user: 'test',
pass: 'test'
});
mockServer.on('stdout', process.stdout.write.bind(process.stdout));
mockServer.on('stderr', process.stderr.write.bind(process.stderr));
setTimeout(function () {
ftp = new JSFtp({
host: 'localhost',
port: 3334,
user: 'test',
pass: 'test'
});
done();
}, 500);
});
after(function () {
mockServer.stop();
fs.rmdirSync(__dirname + '/foo/bar/baz');
fs.rmdirSync(__dirname + '/foo/bar');
fs.rmdirSync(__dirname + '/foo');
});
it('should decorate JSFtp', function () {
assert.equal(typeof ftp.mkdirp, 'function');
});
it('should create nested directories', function (done) {
ftp.mkdirp(testDir, function (err) {
assert(fs.existsSync(__dirname + testDir));
done();
});
});