Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "bal-util", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Common utility functions for Node.js used and maintained by Benjamin Lupton", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/balupton/bal-util.npm", |
@@ -39,3 +39,3 @@ # Balupton's Node.js Utility Functions | ||
- v0.2 May 20, 2011 | ||
- Added some tests with Vows | ||
- Added some tests with expresso | ||
- util.scandir now returns err,list,tree | ||
@@ -42,0 +42,0 @@ - Added util.writetree |
@@ -1,2 +0,1 @@ | ||
var vows = require('vows'); | ||
var assert = require('assert'); | ||
@@ -10,2 +9,3 @@ var coffee = require('coffee-script'); | ||
outPath = __dirname+'/out', | ||
nonPath = __dirname+'/asd', | ||
writetree = { | ||
@@ -44,99 +44,93 @@ 'index.html': '<html>', | ||
vows.describe('bal-util/util').addBatch({ | ||
'writetree': { | ||
topic: function(){ | ||
util.writetree( | ||
// Path | ||
srcPath, | ||
// Tree | ||
writetree, | ||
// Complete | ||
this.callback | ||
); | ||
}, | ||
'did not error': function(err){ | ||
assert.equal(err,false); | ||
}, | ||
'scandir': { | ||
topic: function() { | ||
callback = this.callback; | ||
util.scandir(srcPath,false,false,function(err,list,tree){ | ||
callback(null,err,list,tree); | ||
}); | ||
}, | ||
'did not error': function(z,err,list,tree){ | ||
assert.equal(err,false); | ||
}, | ||
'files were written': function(z,err,list,tree){ | ||
assert.deepEqual(tree,scantree); | ||
}, | ||
'cpdir': { | ||
topic: function(){ | ||
callback = this.callback; | ||
util.cpdir(srcPath,outPath,function(err){ | ||
callback(null,err); | ||
}); | ||
}, | ||
'did not error': function(z,err,list,tree){ | ||
assert.equal(err,false); | ||
}, | ||
'scandir': { | ||
topic: function() { | ||
callback = this.callback; | ||
util.scandir(srcPath,false,false,function(err,list,tree){ | ||
callback(null,err,list,tree); | ||
// Tests | ||
var tests = { | ||
'writetree': function(beforeExit){ | ||
var nTests = 6, nTestsCompleted = 0; | ||
// writetree | ||
util.writetree(srcPath,writetree,function(err){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writetree: no error'); | ||
// scandir | ||
util.scandir(srcPath,false,false,function(err,list,tree){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writetree: scandir: no error'); | ||
// files were written | ||
assert.deepEqual(tree,scantree, 'writetree: scandir: files were written'); | ||
// cpdir | ||
util.cpdir(srcPath,outPath,function(err){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writree: scandir: cpdir: no error'); | ||
// scandir | ||
util.scandir(srcPath,false,false,function(err,list,tree){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: no error'); | ||
// files were copied | ||
assert.deepEqual(tree,scantree, 'writree: scandir: cpdir: scandir: files were copied'); | ||
// rmdir | ||
util.rmdir(srcPath,function(err){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: rmdir: no error'); | ||
// dir was deleted | ||
var exists = path.existsSync(srcPath); | ||
assert.equal(exists,false, 'writree: scandir: cpdir: scandir: rmdir: delete successful'); | ||
}); | ||
}, | ||
'did not error': function(z,err,list,tree){ | ||
assert.equal(err,false); | ||
}, | ||
'files were copied': function(z,err,list,tree){ | ||
assert.deepEqual(tree,scantree); | ||
}, | ||
'rmdir-src': { | ||
topic: function(){ | ||
callback = this.callback; | ||
util.rmdir(srcPath,function(err){ | ||
console.log('Ignore the error about to happen, as seeing this proves the callback did fire'); | ||
callback(null,err); | ||
}); | ||
}, | ||
'did not error': function(z,err){ | ||
assert.equal(err||false,false); | ||
}, | ||
'path.exists': function(){ | ||
var exists = path.existsSync(srcPath); | ||
assert.equal(exists,false); | ||
} | ||
}, | ||
'rmdir-out': { | ||
topic: function(){ | ||
callback = this.callback; | ||
util.rmdir(outPath,function(err){ | ||
callback(null,err); | ||
}); | ||
}, | ||
'did not error': function(z,err){ | ||
assert.equal(err||false,false); | ||
}, | ||
'path.exists': function(){ | ||
// rmdir | ||
util.rmdir(outPath,function(err){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: rmdir: no error'); | ||
// dir was deleted | ||
var exists = path.existsSync(outPath); | ||
assert.equal(exists,false); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
assert.equal(exists,false, 'writree: scandir: cpdir: scandir: rmdir: delete successful'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
// async | ||
beforeExit(function(){ | ||
assert.equal(nTests, nTestsCompleted, 'all writetree tests ran'); | ||
}); | ||
}, | ||
'rmdir-non': function(beforeExit){ | ||
var nTests = 1, nTestsCompleted = 0; | ||
// rmdir | ||
util.rmdir(nonPath,function(err){ | ||
++nTestsCompleted; | ||
// no error | ||
assert.equal(err||false,false, 'rmdir-non: no error'); | ||
}); | ||
// async | ||
beforeExit(function(){ | ||
assert.equal(nTests, nTestsCompleted, 'all rmdir tests ran'); | ||
}); | ||
} | ||
}).export(module); | ||
}; | ||
function assertError(assertion, value, fail) { | ||
try { | ||
assertion(value); | ||
fail = true; | ||
} catch (e) {/* Success */} | ||
fail && assert.fail(value, assert.AssertionError, | ||
'expected an AssertionError for {actual}', | ||
'assertError', assertError); | ||
} | ||
// Export | ||
module.exports = tests; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3
287167
5915