Add test suite for snippet.lua module
Overview
The snippet.lua module (~47 lines) handles snippet insertion with variable expansion. No tests currently exist.
Functions Needing Tests
Public Functions
-
insert_snippet()- Main entry point- Test: displays snippet picker
- Test: handles snippet selection
- Test: handles no snippets found
- Test: handles .zk directory not found
- Test: handles user cancellation
Internal Functions
-
insert_snippet(zk_dir, notebook_dir, snippet_name)- Insert snippet with expansion- Test: reads snippet file correctly
- Test: expands template variables
- Test: inserts at cursor position
- Test: handles multi-line snippets
- Test: handles snippet file not found
- Test: handles file read errors
- Test: preserves cursor position after insertion
Integration Tests
- Test: snippet with {{date}} variable
- Test: snippet with {{input:prompt}} variable
- Test: snippet with {{clipboard}} variable
- Test: snippet with custom variables
- Test: snippet insertion doesn't affect other buffer content
- Test: undo works correctly after snippet insertion
Edge Cases
- Empty snippet file
- Snippet with no variables
- Very large snippet file
- Binary file instead of text
- Unicode content in snippet
Test File Location
tests/zk-extras/snippet_spec.lua
Priority
Medium - Important feature but smaller module