From 515ea9661632badcec2ada304a84637a7397491a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 9 Apr 2026 18:08:19 +0300 Subject: [PATCH] refactor(core): cleanup expected fails --- .../trilium-core/src/services/utils/index.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/trilium-core/src/services/utils/index.spec.ts b/packages/trilium-core/src/services/utils/index.spec.ts index 398cad7161..3d065cca1c 100644 --- a/packages/trilium-core/src/services/utils/index.spec.ts +++ b/packages/trilium-core/src/services/utils/index.spec.ts @@ -465,11 +465,19 @@ describe("#toMap", () => { expect(result).toBeInstanceOf(Map); expect(result.size).toBe(0); }); - it.fails("should correctly handle duplicate keys? (currently it will overwrite the entry, so returned size will be 1 instead of 2)", () => { - const testList = [ { title: "testDupeTitle", propA: "text", propB: 123 }, { title: "testDupeTitle", propA: "prop2", propB: 456 } ]; + it("collapses entries when keys collide (last write wins)", () => { + // Documents the current contract of toMap: when two entries share a + // key, the later entry overwrites the earlier one. See the TODO in + // toMap itself — if the contract ever changes to preserve duplicates + // (e.g. returning Map), update this test along with the change. + const testList = [ + { title: "testDupeTitle", propA: "text", propB: 123 }, + { title: "testDupeTitle", propA: "prop2", propB: 456 } + ]; const result = utils.toMap(testList, "title"); expect(result).toBeInstanceOf(Map); - expect(result.size).toBe(2); + expect(result.size).toBe(1); + expect(result.get("testDupeTitle")?.propA).toBe("prop2"); }); });