feat(requestSnippets): handle type: string, format: binary or base64 file upload data (#7545)

* test(curlify): assert that data-binary is generated

Co-authored-by: Tim Lai <timothy.lai@gmail.com>
This commit is contained in:
Mahtis Michel
2022-01-31 20:34:45 +01:00
committed by GitHub
parent e8cc851c90
commit 2b30a3478d
2 changed files with 24 additions and 4 deletions

View File

@@ -220,6 +220,21 @@ 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'")
})
it("should print a curl with data-binary if body is instance of File and it is not a multipart form data request", function () {
let file = new win.File([""], "file.txt", { type: "" })
let req = {
url: "http://example.com",
method: "POST",
headers: { "content-type": "application/octet-stream" },
body: file
}
let curlified = curl(Im.fromJS(req))
expect(curlified).toEqual("curl -X 'POST' \\\n 'http://example.com' \\\n -H 'content-type: application/octet-stream' \\\n --data-binary '@file.txt'")
})
it("prints a curl post statement from an object", function () {
let req = {
url: "http://example.com",