Skip to content

Commit 687d495

Browse files
authored
test: Add a test case (#4)
1 parent d1c1d48 commit 687d495

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/parse.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ describe("invalid key detection", () => {
104104
expect(issue.key).toBe("");
105105
expect(issue.path).toEqual([]);
106106
});
107+
108+
it("handles non-string keys gracefully if they occur", () => {
109+
const fd = new FormData();
110+
// Handle cases where null or undefined keys might be injected
111+
// by specific environments or legacy polyfills.
112+
fd.append(null as any, "value");
113+
114+
const result = parse(fd);
115+
expect(result.data).toBeNull();
116+
expect(result.issues[0]?.code).toBe("invalid_key");
117+
});
107118
});
108119

109120
describe("boundary constraints", () => {

0 commit comments

Comments
 (0)