From 0b292f2e824ab6f04de82dfbc6c8216829793bd3 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 21 Feb 2024 23:16:54 +0100 Subject: [PATCH] Allow ts tests --- packages/string-templates/jest.config.js | 1 + packages/string-templates/src/index.ts | 6 +++++- packages/string-templates/test/basic.spec.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/string-templates/jest.config.js b/packages/string-templates/jest.config.js index c6391cdb92..4916ebf894 100644 --- a/packages/string-templates/jest.config.js +++ b/packages/string-templates/jest.config.js @@ -4,6 +4,7 @@ */ module.exports = { + preset: "ts-jest", // All imported modules in your tests should be mocked automatically // automock: false, diff --git a/packages/string-templates/src/index.ts b/packages/string-templates/src/index.ts index 5fc9af9573..bf5a250c21 100644 --- a/packages/string-templates/src/index.ts +++ b/packages/string-templates/src/index.ts @@ -102,7 +102,11 @@ export async function processObject(object, context, opts) { * @param {object|undefined} [opts] optional - specify some options for processing. * @returns {Promise} The enriched string, all templates should have been replaced if they can be. */ -export async function processString(string, context, opts) { +export async function processString( + string: string, + context: object, + opts?: { noHelpers: boolean } +) { // TODO: carry out any async calls before carrying out async call return processStringSync(string, context, opts) } diff --git a/packages/string-templates/test/basic.spec.ts b/packages/string-templates/test/basic.spec.ts index e096a3fe45..b1e2865486 100644 --- a/packages/string-templates/test/basic.spec.ts +++ b/packages/string-templates/test/basic.spec.ts @@ -76,7 +76,7 @@ describe("Test that the object processing works correctly", () => { it("should fail gracefully when object passed in has cycles", async () => { let error = null try { - const innerObj = { a: "thing {{ a }}" } + const innerObj: any = { a: "thing {{ a }}" } innerObj.b = innerObj await processObject(innerObj, { a: 1 }) } catch (err) {