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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user