diff --git a/yaml/stringify_test.ts b/yaml/stringify_test.ts index 6e69c349b..5a989d79d 100644 --- a/yaml/stringify_test.ts +++ b/yaml/stringify_test.ts @@ -698,3 +698,32 @@ Deno.test("stringify() returns emtpy array on invalid entries", () => { "[]\n", ); }); + +Deno.test({ + name: + "stringify() handles undefined object entry with skipInvalid and flowLevel option", + fn() { + assertEquals( + stringify({ foo: { bar: undefined } }, { + flowLevel: 1, + skipInvalid: true, + }), + `foo: {}\n`, + ); + }, +}); + +Deno.test({ + name: + "stringify() handles undefined object entry with big key and skipInvalid and flowLevel option", + fn() { + const key = "a".repeat(1025); + assertEquals( + stringify({ [key]: { bar: undefined } }, { + flowLevel: 1, + skipInvalid: true, + }), + `? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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