[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
This commit is contained in:
Gregor Martynus
2019-11-14 16:11:16 -08:00
committed by Pranav Senthilnathan
parent c8287ed1e7
commit d36a3b44e4
2 changed files with 8 additions and 0 deletions

View File

@@ -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"});

View File

@@ -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
*/