mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Use createSinonStub
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
import sinon, { SinonStub } from "sinon";
|
||||
|
||||
/**
|
||||
* createSinonStub assist in setting up a stub with different
|
||||
* return paths.
|
||||
*
|
||||
* e.g.
|
||||
* ```
|
||||
* const s = sinon.stub();
|
||||
* s.throws();
|
||||
* s.withArgs("a").returns(0);
|
||||
* s.withArgs("b").returns(1);
|
||||
* ```
|
||||
* is equivalent to.
|
||||
* ```
|
||||
* const s = createSinonStub(
|
||||
* s => s.throws(),
|
||||
* s => s.withArgs("a").returns(0),
|
||||
* s => s.withArgs("b").returns(1),
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export default function createSinonStub(
|
||||
...callbacks: Array<(s: SinonStub) => void>
|
||||
): SinonStub {
|
||||
|
||||
Reference in New Issue
Block a user