From c9ee81c5dca34377628873287600e7df1278dc3c Mon Sep 17 00:00:00 2001 From: lucaronin Date: Fri, 1 May 2026 04:06:02 +0200 Subject: [PATCH] test: cover locale-stable note subtitles --- src/utils/noteListHelpers.extra.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/utils/noteListHelpers.extra.test.ts b/src/utils/noteListHelpers.extra.test.ts index 9f1f67af..448667a8 100644 --- a/src/utils/noteListHelpers.extra.test.ts +++ b/src/utils/noteListHelpers.extra.test.ts @@ -41,6 +41,7 @@ describe('noteListHelpers extra coverage', () => { }) afterEach(() => { + vi.restoreAllMocks() vi.useRealTimers() }) @@ -76,6 +77,28 @@ describe('noteListHelpers extra coverage', () => { expect(formatSearchSubtitle(modifiedEntry)).toBe('1h ago · Created 2d ago · 1,200 words · 2 links') }) + it('keeps note subtitle counts stable under non-English default number formatting', () => { + const originalToLocaleString = Number.prototype.toLocaleString + vi.spyOn(Number.prototype, 'toLocaleString').mockImplementation(function ( + this: number, + locales?: Intl.LocalesArgument, + options?: Intl.NumberFormatOptions, + ) { + return originalToLocaleString.call(this, locales ?? 'de-DE', options) + }) + + const entry = makeEntry({ + title: 'Project', + modifiedAt: Math.floor(Date.now() / 1000) - 3600, + createdAt: Math.floor(Date.now() / 1000) - 86400 * 2, + wordCount: 1200, + outgoingLinks: ['alpha', 'beta'], + }) + + expect(formatSubtitle(entry)).toBe('1h ago · 1,200 words · 2 links') + expect(formatSearchSubtitle(entry)).toBe('1h ago · Created 2d ago · 1,200 words · 2 links') + }) + it('extracts sortable properties and labels custom property sort keys', () => { const entries = [ makeEntry({ properties: { Priority: 'High', Owner: 'Luca' } }),