test: cover locale-stable note subtitles
This commit is contained in:
@@ -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' } }),
|
||||
|
||||
Reference in New Issue
Block a user