From 3045ac01582a56cb41810b19dc622a7569ca4d0e Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Fri, 30 Nov 2012 02:41:39 +0100 Subject: [PATCH] js: Add description and params list to API functions --- js/src/mopidy.js | 2 ++ js/test/mopidy-test.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/js/src/mopidy.js b/js/src/mopidy.js index be1d62be..5dbee57e 100644 --- a/js/src/mopidy.js +++ b/js/src/mopidy.js @@ -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); diff --git a/js/test/mopidy-test.js b/js/test/mopidy-test.js index 80155d2f..35317378 100644 --- a/js/test/mopidy-test.js +++ b/js/test/mopidy-test.js @@ -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 () {