122 lines
No EOL
2.7 KiB
Markdown
122 lines
No EOL
2.7 KiB
Markdown
# JQuote Plugin Tests
|
|
|
|
This directory contains the comprehensive test suite for the JQuote Neovim plugin.
|
|
|
|
## Test Structure
|
|
|
|
- `init_spec.lua` - Main test file containing all unit tests
|
|
- `test_runner.lua` - Custom lightweight test runner
|
|
- `README.md` - This file
|
|
|
|
## Running Tests
|
|
|
|
### Using Make (Recommended)
|
|
```bash
|
|
# Run all tests
|
|
make test
|
|
|
|
# Run tests with verbose output
|
|
make test-verbose
|
|
|
|
# Run development checks (syntax + tests)
|
|
make dev-check
|
|
```
|
|
|
|
### Direct Execution
|
|
```bash
|
|
# Run tests directly
|
|
lua tests/test_runner.lua
|
|
|
|
# Or from project root
|
|
cd /path/to/jquote.nvim && lua tests/test_runner.lua
|
|
```
|
|
|
|
## Test Categories
|
|
|
|
### 1. Plugin Initialization Tests
|
|
- Default configuration validation
|
|
- User option merging
|
|
- Configuration validation
|
|
- Key mapping setup
|
|
|
|
### 2. Quote Detection Tests
|
|
- Finding quoted strings at cursor
|
|
- Quote character cycling
|
|
- Nested quote handling
|
|
- Multiple quote pairs
|
|
|
|
### 3. Auto Jump Functionality Tests
|
|
- Auto jump to next quote pair
|
|
- Manual mode behavior
|
|
- Edge case handling
|
|
|
|
### 4. Error Handling Tests
|
|
- API failure scenarios
|
|
- Invalid input handling
|
|
- Long line safety limits
|
|
- Resource cleanup
|
|
|
|
### 5. Version Management Tests
|
|
- Git tag version extraction
|
|
- Fallback version handling
|
|
- Semantic version validation
|
|
|
|
### 6. Health Check Tests
|
|
- Configuration validation
|
|
- Plugin state reporting
|
|
- Diagnostic information
|
|
|
|
### 7. Edge Cases Tests
|
|
- Boundary conditions
|
|
- Empty configurations
|
|
- Single character strings
|
|
- Line boundary quotes
|
|
|
|
## Test Output
|
|
|
|
The test runner provides colored output:
|
|
- 🟢 Green: Passed tests
|
|
- 🔴 Red: Failed tests
|
|
- 🔵 Blue: Test categories
|
|
- 🟡 Yellow: Warnings and info
|
|
|
|
## Mock System
|
|
|
|
Tests use a comprehensive vim API mock that simulates:
|
|
- Line content and cursor position
|
|
- Notification system
|
|
- Key mapping
|
|
- Configuration deep merging
|
|
- API error scenarios
|
|
|
|
## Adding New Tests
|
|
|
|
To add new tests, follow this pattern:
|
|
|
|
```lua
|
|
describe("New Feature", function()
|
|
it("should do something specific", function()
|
|
-- Setup
|
|
mock_vim._set_line_and_cursor("test line", 5)
|
|
|
|
-- Execute
|
|
local result = jquote.some_function()
|
|
|
|
-- Assert
|
|
assert.is_true(result)
|
|
assert.are.equal("expected", mock_vim._current_line)
|
|
end)
|
|
end)
|
|
```
|
|
|
|
## Best Practices
|
|
|
|
1. **Isolation**: Each test should be independent
|
|
2. **Clear Names**: Use descriptive test names
|
|
3. **Setup/Teardown**: Use `before_each` for test setup
|
|
4. **Comprehensive**: Test both success and failure paths
|
|
5. **Edge Cases**: Include boundary condition tests
|
|
|
|
## Continuous Integration
|
|
|
|
These tests are designed to run in CI environments and provide detailed feedback for development workflows. |