e067243f7fa18284ea80c12703938c9f79db579e.svn-base
1.04 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
/**
* Temporary - The lord of tmp.
*
* Author: Veselin Todorov <hi@vesln.com>
* Licensed under the MIT License.
*/
/**
* Dependencies.
*/
var fs = require('fs');
var path = require('path');
var existsSync = fs.existsSync || path.existsSync;
var Tempdir = require('../lib/dir');
var sinon = require('sinon');
var should = require('chai').should();
describe('Tempdir', function() {
it('should create file', function() {
var tmp = new Tempdir('foo');
existsSync(tmp.path).should.be.ok;
});
describe('rmdir', function() {
it('should remove the directory', function() {
var tmp = new Tempdir('foo');
sinon.spy(fs, 'rmdir');
tmp.rmdir();
fs.rmdir.getCall(0).args[0].should.eql(tmp.path);
fs.rmdir.restore();
});
});
describe('rmdirSync', function() {
it('should remove the directory', function() {
var tmp = new Tempdir('foo');
sinon.spy(fs, 'rmdirSync');
tmp.rmdirSync();
fs.rmdirSync.getCall(0).args[0].should.eql(tmp.path);
fs.rmdirSync.restore();
});
});
});