Skip to content

Commit 1658179

Browse files
test(utils): add edge case tests for format()
1 parent cd58f16 commit 1658179

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

js/utils/__tests__/utils.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,13 @@ describe("Utility Functions (logic-only)", () => {
709709
expect(obj.viewVar).toBe(20);
710710
expect(obj.modelMethod()).toBe("model");
711711
expect(obj.viewMethod()).toBe("view");
712+
it("should return empty string for missing nested property", () => {
713+
const result = format("User: {user.age}", { user: { name: "Alice" } });
714+
expect(result).toBe("User: ");
715+
});
716+
it("should return original string if no placeholders exist", () => {
717+
const result = format("Hello world", { name: "User" });
718+
expect(result).toBe("Hello world");
712719
});
713720
});
714721
});

0 commit comments

Comments
 (0)