js: Add description and params list to API functions

This commit is contained in:
Stein Magnus Jodal 2012-11-30 02:41:39 +01:00
parent fc9ab6053a
commit 3045ac0158
2 changed files with 6 additions and 0 deletions

View File

@ -263,6 +263,8 @@ Mopidy.prototype._createApi = function (methods) {
var methodName = mopidy._snakeToCamel(methodPath.slice(-1)[0]);
var object = createObjects(methodPath.slice(0, -1));
object[methodName] = caller(fullMethodName);
object[methodName].description = methods[fullMethodName].description;
object[methodName].params = methods[fullMethodName].params;
};
Object.keys(methods).forEach(createMethod);

View File

@ -591,7 +591,11 @@ buster.testCase("Mopidy", {
});
assert.isFunction(this.mopidy.hello);
assert.equals(this.mopidy.hello.description, "Says hello");
assert.equals(this.mopidy.hello.params, []);
assert.isFunction(this.mopidy.hi);
assert.equals(this.mopidy.hi.description, "Says hi");
assert.equals(this.mopidy.hi.params, []);
},
"can create an API with methods on a sub-object": function () {