feature(cloudcmd) add execon from bower

This commit is contained in:
coderaiser 2015-10-21 03:19:22 -04:00
parent 5fc8127230
commit 1c3a117d02
10 changed files with 83 additions and 314 deletions

View file

@ -25,62 +25,6 @@
should(ext).eql(EXT);
});
});
describe('exec', function() {
it('should execute function with parameters', function() {
var WORD = 'hello',
func = function(word) {
return word;
},
word = Util.exec(func, WORD);
WORD.should.equal(word);
});
it('should not execute function, if type of first argument not function', function() {
var WORD = 'hello',
word = Util.exec(WORD);
(word === undefined).should.be.true;
});
});
describe('exec.ret', function() {
it('should return function that try to call callback', function() {
var STR = 'hello world',
func1 = function() {
var args = [].slice.call(arguments);
return args.join(' ');
},
func2 = Util.exec.ret(func1, 'hello'),
str = func2('world');
str.should.be.equal(STR);
});
});
describe('exec.parallel', function() {
it('should execute a couple functions async and return results in callback', function() {
var WORD = 'hello world',
funcSlow = function(callback) {
setTimeout(function() {
callback(null, 'hello');
}, 10);
},
funcFast = function(callback) {
setTimeout(function() {
callback(null, 'world');
}, 1);
};
Util.exec.parallel([funcSlow, funcFast], function(error, hello, world) {
WORD.should.equal(hello + ' ' + world);
});
});
});
});
})();