mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
toFormData helper function (#3757)
* adding toFormData test * adding toFormData Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
var toFormData = require("../../../lib/helpers/toFormData");
|
||||
|
||||
describe("toFormData", function () {
|
||||
it("Convert nested data object to FormDAta", function () {
|
||||
var o = {
|
||||
val: 123,
|
||||
nested: {
|
||||
arr: ["hello", "world"],
|
||||
},
|
||||
};
|
||||
|
||||
convertedVal = toFormData(o);
|
||||
expect(convertedVal instanceof FormData).toEqual(true);
|
||||
expect(Array.from(convertedVal.keys()).length).toEqual(3);
|
||||
expect(convertedVal.get("val")).toEqual("123")
|
||||
expect(convertedVal.get("nested.arr.0")).toEqual("hello")
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user