nextcloud/apps
Daniel Calviño Sánchez b70b38ce31 Fix constructor spy in unit test with Sinon 4.1.3
When a constructor is spied using Sinon it is wrapped by a proxy
function, which calls the original constructor when invoked. When "new
Foo()" is executed a "Foo" object is created, "Foo" is invoked with the
object as "this", and the object is returned as the result of the whole
"new" expression.

Before Sinon 4.1.3 the proxy called the original constructor directly
using the "thisValue" of the spied call; "thisValue" was the object
created by the "new" operator that called the proxy. The proxy assigned
"thisValue" to "returnValue", so it was also the value returned by the
proxy and, in turn, the value returned by the whole "new" expression.

Since Sinon 4.1.3 (see pull request 1626) the proxy calls the original
constructor using "new" instead of directly. The "thisValue" created by
the outermost "new" (the one that called the proxy) is no longer used by
the original constructor; the internal "new" creates a new object, which
is the one passed to the original constructor and returned by the
internal "new" expression. This object is also the value returned by the
proxy ("returnValue") and, in turn, the value returned by the whole
outermost "new" expression.

Thus, now "returnValue" should be used instead of "thisValue" to get the
object created by the spied constructor.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2017-12-08 21:26:45 +01:00
..
admin_audit Update license headers 2017-11-06 16:56:19 +01:00
comments [tx-robot] updated from transifex 2017-12-06 01:10:23 +00:00
dav Merge pull request #7395 from nextcloud/remove-unused 2017-12-06 13:09:01 +01:00
encryption [tx-robot] updated from transifex 2017-11-12 01:10:00 +00:00
federatedfilesharing [tx-robot] updated from transifex 2017-11-23 01:09:47 +00:00
federation Actually set the status so we don't cause another exception 2017-11-29 16:37:54 +01:00
files [tx-robot] updated from transifex 2017-12-07 01:10:37 +00:00
files_external [tx-robot] updated from transifex 2017-12-07 01:10:37 +00:00
files_sharing Fix constructor spy in unit test with Sinon 4.1.3 2017-12-08 21:26:45 +01:00
files_trashbin [tx-robot] updated from transifex 2017-12-02 01:10:32 +00:00
files_versions [tx-robot] updated from transifex 2017-12-08 01:10:13 +00:00
lookup_server_connector LookupServerConnector Autoloader 2017-10-24 20:40:12 +02:00
oauth2 [tx-robot] updated from transifex 2017-12-07 01:10:37 +00:00
provisioning_api Change @georgehrke's email 2017-11-06 20:38:59 +01:00
sharebymail [tx-robot] updated from transifex 2017-11-20 01:09:40 +00:00
systemtags [tx-robot] updated from transifex 2017-12-08 01:10:13 +00:00
testing Update license headers 2017-11-06 16:56:19 +01:00
theming [tx-robot] updated from transifex 2017-12-07 01:10:37 +00:00
twofactor_backupcodes [tx-robot] updated from transifex 2017-11-12 01:10:00 +00:00
updatenotification Make isUpdateAvailable non-static 2017-11-25 12:01:02 +01:00
user_ldap [tx-robot] updated from transifex 2017-12-08 01:10:13 +00:00
workflowengine [tx-robot] updated from transifex 2017-11-30 01:13:19 +00:00