js: Add callingConvention setting
For now it defaults to the existing behavior "by-position-only" and changing it has no effect.
This commit is contained in:
parent
198bd8af6c
commit
858a6977df
@ -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.
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
@ -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]
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user