From 45cf0334f18e6908ebe8b9543264b08ad3d059b6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 29 Jan 2025 21:30:53 +0100 Subject: [PATCH] test(server/utils): add tests for stripTags --- src/services/utils.spec.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/services/utils.spec.ts b/src/services/utils.spec.ts index 49adcc0f4..0b54d6d95 100644 --- a/src/services/utils.spec.ts +++ b/src/services/utils.spec.ts @@ -91,7 +91,28 @@ describe.todo("#unescapeHtml", () => {}); describe.todo("#toObject", () => {}); -describe.todo("#stripTags", () => {}); +describe("#stripTags", () => { + + //pre + const htmlWithNewlines = +`

abc +def

+

ghi

`; + + const testCases: TestCase[] = [ + ["should strip all tags and only return the content, leaving new lines and spaces in tact", [htmlWithNewlines], "abc\ndef\nghi"], + //TriliumNextTODO: should this actually insert a space between content to prevent concatenated text? + ["should strip all tags and only return the content", ["

abc

def

"], "abcdef"], + ]; + + testCases.forEach(testCase => { + const [desc, fnParams, expected] = testCase; + it(desc, () => { + const result = utils.stripTags(...fnParams); + expect(result).toStrictEqual(expected); + }) + }); +}); describe.todo("#union", () => {});