cmorten / superoak

HTTP assertions for Oak made easy via SuperDeno. 🐿 🦕
https://cmorten.github.io/superoak/
MIT License
121 stars 8 forks source link

Does not send correctly an application/x-www-form-urlencoded #27

Closed DanielRamosAcosta closed 2 years ago

DanielRamosAcosta commented 2 years ago

Issue

Setup:

Details

When sending a form like:

superoak(app)
  .post("/")
  .type("form")
  .field("hello", "world")
  .field("foo", "bar")

Instead of receiving {hello: "world", foo: "bar"} I'm receiving the following:

{
  "------9219543305020510994576475827\r\nContent-Disposition: form-data; name": '"hello"\r\n\r\nworld\r\n------9219543305020510994576475827\r\nContent-Disposition: form-data; name="foo"\r\n\r\n...'
}

I'm going to open a PR with a failing test to validate this

cmorten commented 2 years ago

Afaik there may have been some confusion here…

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST#example for some examples highlighting the request differences.

Instead try…

const request = await superoak(app);

await request.post("/")
  .send("hello=world&foo=bar");

or similar variations 😄

DanielRamosAcosta commented 2 years ago

That's right!

I ended doing:

await request.post("/")
  .type("form")
  .send({ hello: "world", foo: "bar" })