diff --git a/package.json b/package.json index 93326db..e0d780c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ ], "license": "MIT", "scripts": { - "install": "node ./build.js" + "install": "node ./build.js", + "test": "node test.js" }, "dependencies": { "bindings": "~1.2.1", diff --git a/test.js b/test.js index fa4ca1c..c558abe 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ var deasync = require('./index.js'); var cp = require('child_process'); var http = require('http'); +const assert = require("assert"); var exec = deasync(cp.exec); @@ -26,6 +27,13 @@ setTimeout(function () { console.log('async'); }, 1000); +var response = 42; +var test = deasync(function(done) { + done(null, response); +}); +var result = test(); +assert(result === response); + console.log(exec('ls -la')); sleep(2000); console.log(request('http://nodejs.org'));