From 85a4f89e8461dc424c504b5f7e7516dc105a6355 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 11 Feb 2015 16:16:38 +1300 Subject: [PATCH 1/3] Add test for matching request header with regex --- nock/nock-tests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nock/nock-tests.ts b/nock/nock-tests.ts index a209a8c94..00227dfaf 100644 --- a/nock/nock-tests.ts +++ b/nock/nock-tests.ts @@ -72,7 +72,10 @@ inst = inst.twice(); inst = inst.thrice(); inst = inst.defaultReplyHeaders(value); + inst = inst.matchHeader(str, str); +inst = inst.matchHeader(str, regex); +inst = inst.matchHeader(str, (val: string) => true); inst = inst.delay(num); inst = inst.delayConnection(num); @@ -105,4 +108,4 @@ nock.recorder.rec({ }); strings = nock.recorder.play(); -objects = nock.recorder.play(); \ No newline at end of file +objects = nock.recorder.play(); From 48256bad091ea6dfaabcd7803ab70da394b46631 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 11 Feb 2015 16:17:56 +1300 Subject: [PATCH 2/3] Add overrides for request header matching --- nock/nock.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nock/nock.d.ts b/nock/nock.d.ts index bcf4560ce..db6d5df93 100644 --- a/nock/nock.d.ts +++ b/nock/nock.d.ts @@ -55,7 +55,10 @@ declare module "nock" { replyWithFile(responseCode: number, fileName: string): Scope; defaultReplyHeaders(headers: Object): Scope; + matchHeader(name: string, value: string): Scope; + matchHeader(name: string, regex: RegExp): Scope; + matchHeader(name: string, fn: (value: string) => bool): Scope; filteringPath(regex: RegExp, replace: string): Scope; filteringPath(fn: (path: string) => string): Scope; From a5b7b2c1281943248f0e2ea9f397bc657957a13b Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 11 Feb 2015 16:22:54 +1300 Subject: [PATCH 3/3] bool is not a type :( --- nock/nock.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nock/nock.d.ts b/nock/nock.d.ts index db6d5df93..b6803ca89 100644 --- a/nock/nock.d.ts +++ b/nock/nock.d.ts @@ -58,7 +58,7 @@ declare module "nock" { matchHeader(name: string, value: string): Scope; matchHeader(name: string, regex: RegExp): Scope; - matchHeader(name: string, fn: (value: string) => bool): Scope; + matchHeader(name: string, fn: (value: string) => boolean): Scope; filteringPath(regex: RegExp, replace: string): Scope; filteringPath(fn: (path: string) => string): Scope;