Send URLSearchParams as request body without extra configuration (#2695)

This commit is contained in:
James Cote 2022-01-31 04:12:02 -05:00 committed by GitHub
parent ab4b21dacc
commit 99c6d813d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 3 deletions

View file

@ -212,6 +212,16 @@ o.spec("request", function() {
o(data).deepEquals({a: "/items", b: [{x: "y"}]})
}).then(done)
})
o("works w/ URLSearchParams body", function(done) {
mock.$defineRoutes({
"POST /item": function(request) {
return {status: 200, responseText: JSON.stringify({a: request.url, b: request.body.toString()})}
}
})
request({method: "POST", url: "/item", body: new URLSearchParams({x: "y", z: "w"})}).then(function(data) {
o(data).deepEquals({a: "/item", b: "x=y&z=w"})
}).then(done)
});
o("ignores unresolved parameter via GET", function(done) {
mock.$defineRoutes({
"GET /item/:x": function(request) {