fix: ignore malformed reload entries
This commit is contained in:
40
src/utils/vaultMetadataNormalization.test.ts
Normal file
40
src/utils/vaultMetadataNormalization.test.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { normalizeVaultEntries } from './vaultMetadataNormalization'
|
||||
|
||||
describe('normalizeVaultEntries', () => {
|
||||
it('repairs missing string metadata when the entry path is present', () => {
|
||||
const entries = normalizeVaultEntries([
|
||||
{
|
||||
path: '/vault/alpha-project.md',
|
||||
filename: undefined,
|
||||
title: undefined,
|
||||
aliases: undefined,
|
||||
},
|
||||
], '/vault')
|
||||
|
||||
expect(entries).toHaveLength(1)
|
||||
expect(entries[0]).toMatchObject({
|
||||
path: '/vault/alpha-project.md',
|
||||
filename: 'alpha-project.md',
|
||||
title: 'alpha-project',
|
||||
aliases: [],
|
||||
})
|
||||
})
|
||||
|
||||
it('drops malformed reload entries that do not include a usable path', () => {
|
||||
const entries = normalizeVaultEntries([
|
||||
{ path: '/vault/valid.md', filename: 'valid.md', title: 'Valid' },
|
||||
{ filename: 'missing-path.md', title: 'Missing Path' },
|
||||
{ path: '', filename: 'empty-path.md', title: 'Empty Path' },
|
||||
{ path: 42, filename: 'numeric-path.md', title: 'Numeric Path' },
|
||||
null,
|
||||
], '/vault')
|
||||
|
||||
expect(entries).toHaveLength(1)
|
||||
expect(entries[0]).toMatchObject({
|
||||
path: '/vault/valid.md',
|
||||
filename: 'valid.md',
|
||||
title: 'Valid',
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user