Commit 9533634
committed
test(mcp): add comprehensive tests + restructure to co-located pattern
Implements Issue #28 - First Adapter + Formatters (Tests)
## Test Coverage
### Formatters (30 tests)
- **formatters.test.ts**: CompactFormatter + VerboseFormatter
- Single/multiple result formatting
- Token estimation
- Empty result handling
- Signature inclusion/exclusion
- maxResults option
- **utils.test.ts**: Token estimation utilities
- Text/JSON token estimation
- Truncation to token budgets
- Whitespace normalization
- Accuracy validation (~50% of actual)
### SearchAdapter (25 tests)
- Tool definition validation
- Query validation (empty, non-string)
- Format validation (compact/verbose/invalid)
- Limit validation (1-50 range)
- Score threshold validation (0-1 range)
- Search execution with mocked indexer
- Token estimation comparison
- Empty result handling
### Restructuring
- ✅ Moved ALL tests from `tests/` to co-located `__tests__/`
- ✅ Updated all import paths (simpler, cleaner)
- ✅ Consistent with `packages/core` and `packages/subagents`
- ✅ Works with root vitest.config.ts out of the box
- ✅ 135 total tests pass (7 test files)
## Benefits
- 🎯 Consistency across entire monorepo
- 📁 Tests co-located with source code
- 🔍 Easier discoverability
- 🚀 Simpler import paths
- ✅ Test discovery works automatically1 parent 15e645f commit 9533634
File tree
11 files changed
+824
-11
lines changed- packages/mcp-server/src
- adapters/__tests__
- formatters
- __tests__
- server
- __tests__
- protocol/__tests__
- utils/__tests__
11 files changed
+824
-11
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
0 commit comments