Skip to content

Commit a01d774

Browse files
committed
Add tests for nested map and sets
1 parent 8192657 commit a01d774

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/core/test/flattenAttributes.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ describe("flattenAttributes", () => {
349349
expect(result["mySet.[3].nested"]).toBe("object");
350350
});
351351

352+
it("handles nested Set objects correctly", () => {
353+
const mySet = new Set([1, 2, 3, { nested: "object" }]);
354+
const result = flattenAttributes({ mySet });
355+
expect(result["mySet.[0]"]).toBe(1);
356+
expect(result["mySet.[1]"]).toBe(2);
357+
expect(result["mySet.[2]"]).toBe(3);
358+
expect(result["mySet.[3].nested"]).toBe("object");
359+
});
360+
352361
it("handles Map objects correctly", () => {
353362
const myMap = new Map();
354363
myMap.set("key1", "value1");
@@ -362,6 +371,17 @@ describe("flattenAttributes", () => {
362371
expect(result["myMap.123"]).toBe("numeric key");
363372
});
364373

374+
it("handles nested Map objects correctly", () => {
375+
const myMap = new Map();
376+
myMap.set("key1", {
377+
key2: "value2",
378+
key3: 42,
379+
});
380+
const result = flattenAttributes({ myMap });
381+
expect(result["myMap.key1.key2"]).toBe("value2");
382+
expect(result["myMap.key1.key3"]).toBe(42);
383+
});
384+
365385
it("handles File objects correctly", () => {
366386
if (typeof File !== "undefined") {
367387
const file = new File(["content"], "test.txt", {

0 commit comments

Comments
 (0)