test(curlify): add test for multipart request quotes handling (#9096)

Refs #4826
This commit is contained in:
Vladimír Gorej
2023-07-31 09:37:05 +02:00
committed by GitHub
parent 4b0e8a8609
commit 03a0280986

View File

@@ -200,6 +200,27 @@ describe("curlify", function () {
expect(curlified).toEqual("curl -X 'POST' \\\n 'http://example.com' \\\n -H 'content-type: multipart/form-data' \\\n -F 'id=123' \\\n -F 'file=@file.txt;type=text/plain'")
})
it("should print a curl with object formData and file", function () {
let file = new win.File([""], "file.txt", { type: "text/plain" })
let req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "multipart/form-data" },
body: {
options: JSON.stringify({
some_array: ["string"],
max_bar: 300,
}),
file
}
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual(`curl -X 'POST' \\\n 'http://example.com' \\\n -H 'content-type: multipart/form-data' \\\n -F 'options={"some_array":["string"],"max_bar":300}' \\\n -F 'file=@file.txt;type=text/plain'`)
})
it("should print a curl without form data type if type is unknown", function () {
let file = new win.File([""], "file.txt", { type: "" })
// file.name = "file.txt"