2
0
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:
Ben Carp
2021-12-23 10:21:51 +02:00
committed by GitHub
parent c00c4ddd87
commit 99648153ce
2 changed files with 73 additions and 0 deletions
+18
View File
@@ -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")
});
});