Export 0.2.1
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / node_modules / grunt / node_modules / temporary / test / dir.test.js
1 /**
2  * Temporary - The lord of tmp.
3  *
4  * Author: Veselin Todorov <hi@vesln.com>
5  * Licensed under the MIT License.
6  */
7
8 /**
9  * Dependencies.
10  */
11 var fs = require('fs');
12 var path = require('path');
13 var existsSync = fs.existsSync || path.existsSync;
14
15 var Tempdir = require('../lib/dir');
16 var sinon = require('sinon');
17 var should = require('chai').should();
18
19 describe('Tempdir', function() {
20   it('should create file', function() {
21     var tmp = new Tempdir('foo');
22     existsSync(tmp.path).should.be.ok;
23   });
24
25   describe('rmdir', function() {
26     it('should remove the directory', function() {
27       var tmp = new Tempdir('foo');
28       sinon.spy(fs, 'rmdir');
29       tmp.rmdir();
30       fs.rmdir.getCall(0).args[0].should.eql(tmp.path);
31       fs.rmdir.restore();
32     });
33   });
34
35   describe('rmdirSync', function() {
36     it('should remove the directory', function() {
37       var tmp = new Tempdir('foo');
38       sinon.spy(fs, 'rmdirSync');
39       tmp.rmdirSync();
40       fs.rmdirSync.getCall(0).args[0].should.eql(tmp.path);
41       fs.rmdirSync.restore();
42     });
43   });
44 });