Skip to content

Commit

Permalink
reformat the test code
Browse files Browse the repository at this point in the history
  • Loading branch information
samxxu committed Jun 8, 2012
1 parent ef9dc95 commit 576caf1
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions test/ensureDir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ var assert = require('assert');
var existsFunction = fs.exists || path.exists;

function removeDir(dir, depth) {
for (var i = 0, current = dir; i < depth; i++,current = path.dirname(current)) {
fs.rmdirSync(current);
//console.log('[' + current + '] removed');
}
for (var i = 0, current = dir; i < depth; i++, current = path.dirname(current)) {
fs.rmdirSync(current);
//console.log('[' + current + '] removed');
}
}

var dir = '/tmp/path/to/nonexist';
ensureDir(dir, 0755, function(err) {
assert.ifError(err);
existsFunction(dir, function(exists) {
assert.ok(exists, '#ensureDir(notExistingDir) should ensure the dir exists');
removeDir(dir, 3);
});
ensureDir(dir, 0755, function (err) {
assert.ifError(err);
existsFunction(dir, function (exists) {
assert.ok(exists, '#ensureDir(notExistingDir) should ensure the dir exists');
removeDir(dir, 3);
});
});


var relativeDir = './temp/path/to/nonexist';
ensureDir(relativeDir, 0755, function(err) {
assert.ifError(err);
existsFunction(relativeDir, function(exists) {
assert.ok(exists, '#ensureDir(relativeDir) should ensure the dir exists');
removeDir(relativeDir, 4);
});
ensureDir(relativeDir, 0755, function (err) {
assert.ifError(err);
existsFunction(relativeDir, function (exists) {
assert.ok(exists, '#ensureDir(relativeDir) should ensure the dir exists');
removeDir(relativeDir, 4);
});
});

var existingDirectory = __dirname;
ensureDir(existingDirectory, function(err) {
ensureDir(existingDirectory, function (err) {
assert.ifError(err);
existsFunction(existingDirectory, function(exists) {
existsFunction(existingDirectory, function (exists) {
assert.ok(exists, '#ensureDir(existingDir) should ensure the dir exists');
});
});

0 comments on commit 576caf1

Please sign in to comment.