Files
tolaria/src/hooks/frontmatterOps.test.ts
lucaronin 473239be3a test: add tests for usePinnedProperties hook and frontmatter sync
- 10 tests for usePinnedProperties: resolution, defaults, pin/unpin, isPinned
- 3 tests for frontmatterToEntryPatch: _pinned_properties update/delete/ignore

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 10:24:27 +01:00

26 lines
1.0 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { frontmatterToEntryPatch } from './frontmatterOps'
describe('frontmatterToEntryPatch — _pinned_properties', () => {
it('patches pinnedProperties on update', () => {
const result = frontmatterToEntryPatch('update', '_pinned_properties', ['Status:circle-dot', 'Date'])
expect(result.patch.pinnedProperties).toEqual([
{ key: 'Status', icon: 'circle-dot' },
{ key: 'Date', icon: null },
])
expect(result.relationshipPatch).toBeNull()
})
it('clears pinnedProperties on delete', () => {
const result = frontmatterToEntryPatch('delete', '_pinned_properties')
expect(result.patch.pinnedProperties).toEqual([])
expect(result.relationshipPatch).toBeNull()
})
it('ignores non-array _pinned_properties values', () => {
const result = frontmatterToEntryPatch('update', '_pinned_properties', 'not-an-array')
// Falls through to default handling (no patch for unknown keys)
expect(result.patch.pinnedProperties).toBeUndefined()
})
})