ft: utils.createObjWithHashedKeys ft: curlify.extractKey test: curlify with array representation
This commit is contained in:
@@ -143,6 +143,26 @@ describe("curlify", function() {
|
||||
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"name=Sahar\"")
|
||||
})
|
||||
|
||||
it("should print a curl with formData that extracts array representation with hashIdx", function() {
|
||||
// Note: hashIdx = `_**[]${counter}`
|
||||
// Usage of hashIdx is an internal SwaggerUI method to convert formData array into something curlify can handle
|
||||
const req = {
|
||||
url: "http://example.com",
|
||||
method: "POST",
|
||||
headers: { "content-type": "multipart/form-data" },
|
||||
body: {
|
||||
id: "123",
|
||||
"fruits[]_**[]1": "apple",
|
||||
"fruits[]_**[]2": "banana",
|
||||
"fruits[]_**[]3": "grape"
|
||||
}
|
||||
}
|
||||
|
||||
let curlified = curl(Im.fromJS(req))
|
||||
|
||||
expect(curlified).toEqual("curl -X POST \"http://example.com\" -H \"content-type: multipart/form-data\" -F \"id=123\" -F \"fruits[]=apple\" -F \"fruits[]=banana\" -F \"fruits[]=grape\"")
|
||||
})
|
||||
|
||||
it("should print a curl with formData and file", function() {
|
||||
var file = new win.File()
|
||||
file.name = "file.txt"
|
||||
|
||||
Reference in New Issue
Block a user