From 0e4f8ad465b0cf1d1393c9778a0b43e5abdb34d4 Mon Sep 17 00:00:00 2001 From: Piotr Jamroz Date: Mon, 15 Jan 2018 16:29:11 +0000 Subject: [PATCH 1/3] Document async calls --- docs/release-source/release/stubs.md | 44 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/docs/release-source/release/stubs.md b/docs/release-source/release/stubs.md index f6d2f30b2..e89b41db5 100644 --- a/docs/release-source/release/stubs.md +++ b/docs/release-source/release/stubs.md @@ -458,28 +458,50 @@ Useful if a function is called with more than one callback, and simply calling t Like `callArg`, but with arguments. +#### Asynchronous calls -#### `stub.callsArgAsync(index);` +Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. -Same as their corresponding non-Async counterparts, but with callback being deferred (executed not immediately but after short timeout and in another "thread") + * In Node environment the callback is deferred with `process.nextTick`. + * In a browser the callback is deferred with `setTimeout(callback, 0)`. -#### `stub.callsArgAsync(index);` +More information: -#### `stub.callsArgOnAsync(index, context);` + * , + * , + * . -#### `stub.callsArgWithAsync(index, arg1, arg2, ...);` +##### `stub.callsArgAsync(index);` -#### `stub.callsArgOnWithAsync(index, context, arg1, arg2, ...);` +Async version of [stub.callsArg(index)](#stubcallsargindex). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsAsync([arg1, arg2, ...]);` +##### `stub.callsArgOnAsync(index, context);` -Same as their corresponding non-Async counterparts, but with callback being deferred (executed not immediately but after short timeout and in another "thread") +Async version of [stub.callsArgOn(index, context)](#stubcallsargonindex-context). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsOnAsync(context, [arg1, arg2, ...]);` +##### `stub.callsArgWithAsync(index, arg1, arg2, ...);` -#### `stub.yieldsToAsync(property, [arg1, arg2, ...]);` +Async version of [stub.callsArgWith(index, arg1, arg2, ...)](#stubcallsargwithindex-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsToOnAsync(property, context, [arg1, arg2, ...])` +##### `stub.callsArgOnWithAsync(index, context, arg1, arg2, ...);` + +Async version of [stub.callsArgOnWith(index, context, arg1, arg2, ...)](#stubcallsargonwithindex-context-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsAsync([arg1, arg2, ...]);` + +Async version of [stub.yields([arg1, arg2, ...])](#stubyieldsarg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsOnAsync(context, [arg1, arg2, ...]);` + +Async version of [stub.yieldsOn(context, [arg1, arg2, ...])](#stubyieldsoncontext-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsToAsync(property, [arg1, arg2, ...]);` + +Async version of [stub.yieldsTo(property, [arg1, arg2, ...])](#stubyieldstoproperty-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsToOnAsync(property, context, [arg1, arg2, ...])` + +Async version of [stub.yieldsToOn(property, context, [arg1, arg2, ...])](#stubyieldstoonproperty-context-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). #### `sinon.addBehavior(name, fn);` From d0b139e821915d1e483647cdc38000c62a8d2bc9 Mon Sep 17 00:00:00 2001 From: Piotr Jamroz Date: Mon, 15 Jan 2018 16:40:33 +0000 Subject: [PATCH 2/3] Update docs for the current release --- docs/_releases/v4.1.5/stubs.md | 44 +++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/docs/_releases/v4.1.5/stubs.md b/docs/_releases/v4.1.5/stubs.md index f6d2f30b2..e89b41db5 100644 --- a/docs/_releases/v4.1.5/stubs.md +++ b/docs/_releases/v4.1.5/stubs.md @@ -458,28 +458,50 @@ Useful if a function is called with more than one callback, and simply calling t Like `callArg`, but with arguments. +#### Asynchronous calls -#### `stub.callsArgAsync(index);` +Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. -Same as their corresponding non-Async counterparts, but with callback being deferred (executed not immediately but after short timeout and in another "thread") + * In Node environment the callback is deferred with `process.nextTick`. + * In a browser the callback is deferred with `setTimeout(callback, 0)`. -#### `stub.callsArgAsync(index);` +More information: -#### `stub.callsArgOnAsync(index, context);` + * , + * , + * . -#### `stub.callsArgWithAsync(index, arg1, arg2, ...);` +##### `stub.callsArgAsync(index);` -#### `stub.callsArgOnWithAsync(index, context, arg1, arg2, ...);` +Async version of [stub.callsArg(index)](#stubcallsargindex). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsAsync([arg1, arg2, ...]);` +##### `stub.callsArgOnAsync(index, context);` -Same as their corresponding non-Async counterparts, but with callback being deferred (executed not immediately but after short timeout and in another "thread") +Async version of [stub.callsArgOn(index, context)](#stubcallsargonindex-context). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsOnAsync(context, [arg1, arg2, ...]);` +##### `stub.callsArgWithAsync(index, arg1, arg2, ...);` -#### `stub.yieldsToAsync(property, [arg1, arg2, ...]);` +Async version of [stub.callsArgWith(index, arg1, arg2, ...)](#stubcallsargwithindex-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). -#### `stub.yieldsToOnAsync(property, context, [arg1, arg2, ...])` +##### `stub.callsArgOnWithAsync(index, context, arg1, arg2, ...);` + +Async version of [stub.callsArgOnWith(index, context, arg1, arg2, ...)](#stubcallsargonwithindex-context-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsAsync([arg1, arg2, ...]);` + +Async version of [stub.yields([arg1, arg2, ...])](#stubyieldsarg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsOnAsync(context, [arg1, arg2, ...]);` + +Async version of [stub.yieldsOn(context, [arg1, arg2, ...])](#stubyieldsoncontext-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsToAsync(property, [arg1, arg2, ...]);` + +Async version of [stub.yieldsTo(property, [arg1, arg2, ...])](#stubyieldstoproperty-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). + +##### `stub.yieldsToOnAsync(property, context, [arg1, arg2, ...])` + +Async version of [stub.yieldsToOn(property, context, [arg1, arg2, ...])](#stubyieldstoonproperty-context-arg1-arg2-). See also [Asynchronous calls](#asynchronous-calls). #### `sinon.addBehavior(name, fn);` From 0aeb94ce3ca191e03ed6329796c7dd464840f3ec Mon Sep 17 00:00:00 2001 From: Piotr Jamroz Date: Mon, 15 Jan 2018 22:21:30 +0000 Subject: [PATCH 3/3] Remove redundant indentation Markdown doesn't require indenting the first level. --- docs/_releases/v4.1.5/stubs.md | 10 +++++----- docs/release-source/release/stubs.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/_releases/v4.1.5/stubs.md b/docs/_releases/v4.1.5/stubs.md index e89b41db5..491e58116 100644 --- a/docs/_releases/v4.1.5/stubs.md +++ b/docs/_releases/v4.1.5/stubs.md @@ -462,14 +462,14 @@ Like `callArg`, but with arguments. Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with `process.nextTick`. - * In a browser the callback is deferred with `setTimeout(callback, 0)`. +* In Node environment the callback is deferred with `process.nextTick`. +* In a browser the callback is deferred with `setTimeout(callback, 0)`. More information: - * , - * , - * . +* , +* , +* . ##### `stub.callsArgAsync(index);` diff --git a/docs/release-source/release/stubs.md b/docs/release-source/release/stubs.md index e89b41db5..491e58116 100644 --- a/docs/release-source/release/stubs.md +++ b/docs/release-source/release/stubs.md @@ -462,14 +462,14 @@ Like `callArg`, but with arguments. Same as their corresponding non-Async counterparts, but with callback being deferred at called after all instructions in the current call stack are processed. - * In Node environment the callback is deferred with `process.nextTick`. - * In a browser the callback is deferred with `setTimeout(callback, 0)`. +* In Node environment the callback is deferred with `process.nextTick`. +* In a browser the callback is deferred with `setTimeout(callback, 0)`. More information: - * , - * , - * . +* , +* , +* . ##### `stub.callsArgAsync(index);`