From d36a3b44e4eca80a39633eb6da0fb3ee0dcce8aa Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Thu, 14 Nov 2019 16:11:16 -0800 Subject: [PATCH] [fetch-mock v7.4.0] Add `options.body` for request body matching (#40133) * add tests for request body matching feature added in https://github.com/wheresrhys/fetch-mock/pull/448 * add `options.body` for request body matching See https://github.com/wheresrhys/fetch-mock/pull/448/files * add test to match request body to array --- types/fetch-mock/fetch-mock-tests.ts | 3 +++ types/fetch-mock/index.d.ts | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index 4593933aef..63381591b9 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -111,6 +111,9 @@ fetchMock.get("http://test.com", 200, {method: "GET"}); fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true}); fetchMock.get("http://test.com", 200, {overwriteRoutes: true}); fetchMock.post("http://test.com", 200, {method: "POST"}); +fetchMock.post("http://test.com", 200, {method: "POST", body: "abc"}); +fetchMock.post("http://test.com", 200, {method: "POST", body: {foo: "bar"}}); +fetchMock.post("http://test.com", 200, {method: "POST", body: ["foo", "bar"]}); fetchMock.put("http://test.com", 200, {method: "PUT"}); fetchMock.delete("http://test.com", 200, {method: "DELETE"}); fetchMock.head("http://test.com", 200, {method: "HEAD"}); diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index aa73960ca5..5900068e59 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -144,6 +144,11 @@ declare namespace fetchMock { */ headers?: { [key: string]: string | number }; + /** + * body to match + */ + body?: string | {}; + /** * key/value map of query strings to match, in any order */