test(yaml): add undefined object entry with skipInvalid and flowLevel option test (#5829)

This commit is contained in:
Tim Reichen 2024-08-26 11:56:26 +02:00 committed by GitHub
parent 0ebec10450
commit 3946983d7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,
}),
`? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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