From 55e0145fdb3fe77b8f5d0aa4c9fb451a560411a2 Mon Sep 17 00:00:00 2001 From: andz-bb Date: Thu, 21 Mar 2024 16:10:52 +0000 Subject: [PATCH 1/2] fix for boolean values getting stripped when running processObject --- packages/string-templates/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/string-templates/src/index.ts b/packages/string-templates/src/index.ts index 759fe2dc54..1ac91edd28 100644 --- a/packages/string-templates/src/index.ts +++ b/packages/string-templates/src/index.ts @@ -94,7 +94,7 @@ export async function processObject>( for (const key of Object.keys(object || {})) { if (object[key] != null) { const val = object[key] - let parsedValue + let parsedValue = val if (typeof val === "string") { parsedValue = await processString(object[key], context, opts) } else if (typeof val === "object") { From 09368340de80e325dc5c01a55e3dfcd4a51a982a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 21 Mar 2024 17:29:55 +0100 Subject: [PATCH 2/2] Add tests --- packages/string-templates/test/basic.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/string-templates/test/basic.spec.ts b/packages/string-templates/test/basic.spec.ts index ae006f06f9..00058d4ecd 100644 --- a/packages/string-templates/test/basic.spec.ts +++ b/packages/string-templates/test/basic.spec.ts @@ -104,6 +104,26 @@ describe("Test that the object processing works correctly", () => { } expect(error).toBeNull() }) + + it("should be able to handle booleans", async () => { + const output = await processObject( + { + first: true, + second: "true", + third: "another string", + forth: "with {{ template }}", + }, + { + template: "value", + } + ) + expect(output).toEqual({ + first: true, + second: "true", + third: "another string", + forth: "with value", + }) + }) }) describe("check returning objects", () => {