use decorator

This commit is contained in:
Ryan X. Charles 2014-04-15 16:53:23 -03:00
commit 4241287887
3 changed files with 108 additions and 39 deletions

View file

@ -61,7 +61,7 @@ describe('API', function() {
it('should echo a number', function(done) {
var api = new API();
var num = 500;
api.echo(num, function(err, result) {
api.echoNumber(num, function(err, result) {
result.should.equal(num);
(typeof result).should.equal('number');
done();
@ -73,7 +73,7 @@ describe('API', function() {
it('should echo an object', function(done) {
var api = new API();
var obj = {test:'test'};
api.echo(obj, function(err, result) {
api.echoObject(obj, function(err, result) {
result.test.should.equal(obj.test);
(typeof result).should.equal('object');
done();
@ -81,4 +81,53 @@ describe('API', function() {
});
});
describe('#getArgTypes', function() {
it('should get the argTypes of echo', function(done) {
var api = new API();
api.getArgTypes('echo', function(err, result) {
result[0][1].should.equal('string');
done();
});
});
});
describe('#getCommands', function() {
it('should get all the commands', function(done) {
var api = new API();
var n = 0;
for (var i in api)
if (i[0] != '_' && typeof api[i] == 'function')
n++;
api.getCommands(function(err, result) {
result.length.should.equal(n);
done();
});
});
});
describe('#getPublicKeyRingId', function() {
it('should get a public key ring ID', function(done) {
var api = new API();
api.getPublicKeyRingId(function(err, result) {
result.length.should.be.greaterThan(5);
done();
});
});
});
describe('#help', function() {
it('should call _cmd_getCommands', function(done) {
var api = new API();
api._cmd_getCommands = function(callback) {
(typeof arguments[0]).should.equal('function');
callback(null, ['item']);
}
api.help(function(err, result) {
result[0].should.equal('item');
done();
});
});
});
});