From 9689222fd430de776b6081e95fb0de32d79eaf45 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 29 Jan 2025 19:15:21 +0100 Subject: [PATCH] test(server/utils): add tests for removeTextFileExtension --- src/services/utils.spec.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/services/utils.spec.ts b/src/services/utils.spec.ts index 36eae4e82..92c70268d 100644 --- a/src/services/utils.spec.ts +++ b/src/services/utils.spec.ts @@ -112,7 +112,24 @@ describe.todo("#replaceAll", () => {}); // TriliumNextTODO move existing formatDownloadTitle in here // describe.todo("#formatDownloadTitle", () => {}); -describe.todo("#removeTextFileExtension", () => {}); +describe("#removeTextFileExtension", () => { + const testCases: TestCase[] = [ + ["w/ 'test.md' it should strip '.md'", ["test.md"], "test"], + ["w/ 'test.markdown' it should strip '.markdown'", ["test.markdown"], "test"], + ["w/ 'test.html' it should strip '.html'", ["test.html"], "test"], + ["w/ 'test.htm' it should strip '.htm'", ["test.htm"], "test"], + ["w/ 'test.zip' it should NOT strip '.zip'", ["test.zip"], "test.zip"], + ]; + + testCases.forEach(testCase => { + const [desc, fnParams, expected] = testCase; + it(desc, () => { + const result = utils.removeTextFileExtension(...fnParams); + expect(result).toStrictEqual(expected); + }); + }); + +}); describe.todo("#getNoteTitle", () => {});