diff --git a/src/infra/cli-root-options.test.ts b/src/infra/cli-root-options.test.ts index e6907984ec0..6d7461a39e5 100644 --- a/src/infra/cli-root-options.test.ts +++ b/src/infra/cli-root-options.test.ts @@ -6,8 +6,11 @@ describe("isValueToken", () => { { value: "work", expected: true }, { value: "-1", expected: true }, { value: "-1.5", expected: true }, + { value: "-0.5", expected: true }, { value: "--", expected: false }, { value: "--dev", expected: false }, + { value: "-", expected: false }, + { value: "", expected: false }, { value: undefined, expected: false }, ])("classifies %j", ({ value, expected }) => { expect(isValueToken(value)).toBe(expected); @@ -24,6 +27,8 @@ describe("consumeRootOptionToken", () => { { args: ["--log-level", "-1.5"], index: 0, expected: 2 }, { args: ["--profile", "--no-color"], index: 0, expected: 1 }, { args: ["--profile", "--"], index: 0, expected: 1 }, + { args: ["x", "--profile", "work"], index: 1, expected: 2 }, + { args: ["--log-level", ""], index: 0, expected: 1 }, { args: ["--unknown"], index: 0, expected: 0 }, { args: [], index: 0, expected: 0 }, ])("consumes %j at %d", ({ args, index, expected }) => { diff --git a/src/infra/json-utf8-bytes.test.ts b/src/infra/json-utf8-bytes.test.ts index e2f8e217be0..5009301ffd6 100644 --- a/src/infra/json-utf8-bytes.test.ts +++ b/src/infra/json-utf8-bytes.test.ts @@ -18,6 +18,11 @@ describe("jsonUtf8Bytes", () => { value: undefined, expected: Buffer.byteLength("undefined", "utf8"), }, + { + name: "unicode strings", + value: "🙂", + expected: Buffer.byteLength(JSON.stringify("🙂"), "utf8"), + }, ])("returns utf8 byte length for $name", ({ value, expected }) => { expect(jsonUtf8Bytes(value)).toBe(expected); }); @@ -31,4 +36,8 @@ describe("jsonUtf8Bytes", () => { it("uses string conversion for BigInt serialization failures", () => { expect(jsonUtf8Bytes(12n)).toBe(Buffer.byteLength("12", "utf8")); }); + + it("uses string conversion for symbol serialization failures", () => { + expect(jsonUtf8Bytes(Symbol("token"))).toBe(Buffer.byteLength("Symbol(token)", "utf8")); + }); }); diff --git a/src/infra/plain-object.test.ts b/src/infra/plain-object.test.ts index 892e5c89fab..272c7c94f9d 100644 --- a/src/infra/plain-object.test.ts +++ b/src/infra/plain-object.test.ts @@ -9,10 +9,21 @@ describe("isPlainObject", () => { }, ); - it.each([null, [], new Date(), /re/, "x", 42, () => null, new Map()])( - "rejects non-plain values: %j", - (value) => { - expect(isPlainObject(value)).toBe(false); - }, - ); + it.each([ + null, + [], + new Date(), + /re/, + "x", + 42, + () => null, + new Map(), + { [Symbol.toStringTag]: "Array" }, + ])("rejects non-plain values: %j", (value) => { + expect(isPlainObject(value)).toBe(false); + }); + + it("accepts object-tag values with an explicit Object toStringTag", () => { + expect(isPlainObject({ [Symbol.toStringTag]: "Object" })).toBe(true); + }); });