test: add tests for modified note indicators

- NoteList: 4 tests for modified indicator dot visibility
- TabBar: 3 tests for modified indicator on tabs
- StatusBar: 3 tests for pending count display
- useEditorSave: 2 tests for onAfterSave callback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lucaronin
2026-02-23 21:15:13 +01:00
parent 80096f26b6
commit ca22bca355
4 changed files with 116 additions and 0 deletions

View File

@@ -107,6 +107,43 @@ describe('useEditorSave', () => {
})
})
it('calls onAfterSave callback after successful save', async () => {
const onAfterSave = vi.fn()
const { result } = renderHook(() =>
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave })
)
act(() => {
result.current.handleContentChange('/test/note.md', 'new content')
})
await act(async () => {
await result.current.handleSave()
})
expect(onAfterSave).toHaveBeenCalledOnce()
})
it('does not call onAfterSave when save fails', async () => {
mockInvokeFn.mockRejectedValueOnce(new Error('Disk full'))
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
const onAfterSave = vi.fn()
const { result } = renderHook(() =>
useEditorSave({ updateVaultContent, setTabs, setToastMessage, onAfterSave })
)
act(() => {
result.current.handleContentChange('/test/note.md', 'content')
})
await act(async () => {
await result.current.handleSave()
})
expect(onAfterSave).not.toHaveBeenCalled()
consoleSpy.mockRestore()
})
it('handleContentChange buffers the latest content', () => {
const { result } = renderSaveHook()