423be08a38ee2cc50b77da87503d43424202440d.svn-base
1.5 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
/**
* Temporary - The lord of tmp.
*
* Author: Veselin Todorov <hi@vesln.com>
* Licensed under the MIT License.
*/
/**
* Dependencies.
*/
var path = require('path');
var fs = require('fs');
var existsSync = fs.existsSync || path.existsSync;
var Base = require('../lib/base');
var generator = require('../lib/generator');
var should = require('chai').should();
Base.prototype.create = function() {};
describe('Base', function() {
describe('rename', function() {
it('should rename the directory', function(done) {
var tmp = new Base;
tmp.path = generator.build();
fs.mkdirSync(path.normalize(tmp.path), 0777);
existsSync(tmp.path).should.be.ok;
tmp.rename('foo', function(err) {
existsSync(tmp.path).should.be.ok;
done();
});
});
});
describe('renameSync', function() {
it('should rename the directory', function() {
var tmp = new Base('foo');
tmp.path = generator.build();
fs.mkdirSync(path.normalize(tmp.path), 0777);
var oldPath = tmp.path;
existsSync(tmp.path).should.be.ok;
tmp.renameSync('foo3');
existsSync(tmp.path).should.be.ok;
path.should.not.eql(oldPath);
});
});
describe('prepareArgs', function() {
it('should convert object to array and append path as first element', function() {
var tmp = new Base('foo');
var args = { 0: 'foo' };
args.length = 1;
tmp.path = generator.build();
tmp.prepareArgs(args).should.eql([tmp.path, 'foo']);
});
});
});