mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #12725 from pimterry/nock-optionally-t2
Add optionally() to Nock
This commit is contained in:
3
nock/index.d.ts
vendored
3
nock/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for nock v8.0.0
|
||||
// Type definitions for nock v8.2.0
|
||||
// Project: https://github.com/node-nock/nock
|
||||
// Definitions by: bonnici <https://github.com/bonnici>, Horiuchi_H <https://github.com/horiuchi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -91,6 +91,7 @@ declare namespace nock {
|
||||
once(): this;
|
||||
twice(): this;
|
||||
thrice(): this;
|
||||
optionally(): this;
|
||||
|
||||
delay(opts: number | { head?: number; body?: number; }): this;
|
||||
delayBody(timeMs: number): this;
|
||||
|
||||
@@ -76,6 +76,8 @@ inst = inst.once();
|
||||
inst = inst.twice();
|
||||
inst = inst.thrice();
|
||||
|
||||
inst = inst.optionally();
|
||||
|
||||
scope = scope.defaultReplyHeaders(value);
|
||||
|
||||
scope = scope.matchHeader(str, str);
|
||||
@@ -412,6 +414,9 @@ nock('http://zombo.com').get('/').once().reply(200, 'Ok');
|
||||
nock('http://zombo.com').get('/').twice().reply(200, 'Ok');
|
||||
nock('http://zombo.com').get('/').thrice().reply(200, 'Ok');
|
||||
|
||||
// Make responding optional
|
||||
nock('http://zombo.com').get('/').optionally().reply(200, 'Ok');
|
||||
|
||||
// Delay the response body
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
|
||||
Reference in New Issue
Block a user