diff --git a/docs/api/js.rst b/docs/api/js.rst index 9b851859..7eb86419 100644 --- a/docs/api/js.rst +++ b/docs/api/js.rst @@ -115,6 +115,10 @@ When creating an instance, you can specify the following settings: The maximum number of milliseconds to wait after a connection error before we try to reconnect. Defaults to 64000. +``callingConvention`` + Which calling convention to use when calling methods. The default is + "by-position-only". + ``webSocket`` An existing WebSocket object to be used instead of creating a new WebSocket. Defaults to undefined. diff --git a/js/src/mopidy.js b/js/src/mopidy.js index d3036ff5..b0cea67f 100644 --- a/js/src/mopidy.js +++ b/js/src/mopidy.js @@ -53,6 +53,9 @@ Mopidy.prototype._configure = function (settings) { settings.backoffDelayMin = settings.backoffDelayMin || 1000; settings.backoffDelayMax = settings.backoffDelayMax || 64000; + settings.callingConvention = ( + settings.callingConvention || "by-position-only"); + return settings; }; diff --git a/js/test/mopidy-test.js b/js/test/mopidy-test.js index 781c24d2..f46464cf 100644 --- a/js/test/mopidy-test.js +++ b/js/test/mopidy-test.js @@ -766,20 +766,29 @@ buster.testCase("Mopidy", { assert.calledOnceWith(spy); }, - "creates methods that sends correct messages": function () { - var sendStub = this.stub(this.mopidy, "_send"); - this.mopidy._createApi({ - foo: { - params: ["bar", "baz"] - } - }); + "by-position calling convention": { + "is the default": function () { + assert.equals( + this.mopidy._settings.callingConvention, + "by-position-only"); + }, - this.mopidy.foo(31, 97); + "sends messages with function arguments unchanged": function () { + var sendStub = this.stub(this.mopidy, "_send"); + this.mopidy._createApi({ + foo: { + params: ["bar", "baz"] + } + }); - assert.calledOnceWith(sendStub, { - method: "foo", - params: [31, 97] - }); + this.mopidy.foo(31, 97); + + assert.calledOnceWith(sendStub, { + method: "foo", + params: [31, 97] + }); + }, } + } });