test: cover locale-stable note subtitles

This commit is contained in:
lucaronin
2026-05-01 04:06:02 +02:00
parent 04fa74e8d8
commit c9ee81c5dc

View File

@@ -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' } }),