Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
test(core): reach 100% for services
Elian Doran84b55ad31b67
diff --git a/packages/trilium-core/src/services/in_app_help.spec.ts b/packages/trilium-core/src/services/in_app_help.spec.tsindex 88164b9721..e57da13820 100644--- a/packages/trilium-core/src/services/in_app_help.spec.ts+++ b/packages/trilium-core/src/services/in_app_help.spec.ts@@ -100,4 +100,22 @@ describe("in_app_help - cleanUpHelp", () => {expect(becca.getNote("_helpKeepChild")?.isDeleted).toBe(false);expect(becca.getNote("_help")?.isDeleted).toBe(false);});++ it("is a no-op when the _help subtree does not exist", () => {+ // Remove the whole _help subtree, so becca.getNote("_help") is null and+ // the recursive flattener hits its empty-note short-circuit.+ withContext(() => becca.getNote("_help")?.deleteNote());+ expect(becca.getNote("_help")).toBeNull();++ expect(() => withContext(() => cleanUpHelp([]))).not.toThrow();+ });+});++describe("in_app_help - no provider registered", () => {+ // Runs last: it clears the provider for the rest of this isolated fork.+ it("falls back to defaults when no provider is registered", () => {+ initInAppHelp(undefined as unknown as InAppHelpProvider);+ expect(getHelpHiddenSubtreeData()).toEqual([]);+ expect(() => cleanUpHelp([])).not.toThrow();+ });});diff --git a/packages/trilium-core/src/services/safe_template.spec.ts b/packages/trilium-core/src/services/safe_template.spec.tsindex e255e129e9..6d65a8787c 100644--- a/packages/trilium-core/src/services/safe_template.spec.ts+++ b/packages/trilium-core/src/services/safe_template.spec.ts@@ -81,6 +81,15 @@ describe("safe_template - evaluateTemplate", () => {);});+ it("returns empty string when a no-arg method target along the chain is null", () => {+ // `dateCreatedObj` is whitelisted but null, so the chain resolves to null+ // and the no-arg method call short-circuits to null (rendered empty).+ const note = fakeNote({ dateCreatedObj: null });+ expect(evaluateTemplate("${note.dateCreatedObj.format()}", { note })).toBe(+ ""+ );+ });+it("renders null/undefined results as an empty string", () => {expect(evaluateTemplate("[${note.title}]", {