mirror of
https://github.com/thedotmack/claude-mem.git
synced 2026-09-20 04:23:02 +08:00
2a0a407340
Cuts verified dead code, duplication, and speculative abstractions across 14 disjoint areas of the tree: sqlite layer, worker HTTP routes, search pipeline, server, chroma sync, viewer UI, npx-cli, MCP server, shared/utils, telemetry/infra, integrations, scripts, tests, and stale plans/evals docs. Also unifies the Chroma search pipeline onto SearchOrchestrator/strategies and ports dual-project (merged_into_project) scoping plus dateRange filtering into ChromaSearchStrategy, which corpus builds need but had silently lost. Full audit trail: 65-agent verification workflow wf_160a7862-1a6, 14-agent execution wf_c7e48c0f-164, 6-agent fixup wf_865f86a4-c6b. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { describe, it, expect } from 'bun:test';
|
|
import { toBmpSafe } from '../src/utils/bmp-safe';
|
|
|
|
function hasSurrogate(s: string): boolean {
|
|
for (let i = 0; i < s.length; i++) {
|
|
const code = s.charCodeAt(i);
|
|
if (code >= 0xd800 && code <= 0xdfff) return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
describe('toBmpSafe (issue #2787)', () => {
|
|
it('maps known astral type markers to distinct BMP glyphs', () => {
|
|
expect(toBmpSafe('🔴')).toBe('●');
|
|
expect(toBmpSafe('🟣')).toBe('◆');
|
|
expect(toBmpSafe('🔄')).toBe('↻');
|
|
expect(toBmpSafe('🔵')).toBe('○');
|
|
expect(toBmpSafe('🚨')).toBe('⚠');
|
|
expect(toBmpSafe('🔐')).toBe('⚷');
|
|
});
|
|
|
|
it('degrades unknown astral code points to a BMP bullet', () => {
|
|
expect(toBmpSafe('🦄')).toBe('•');
|
|
expect(toBmpSafe('𐍈')).toBe('•'); // Gothic letter, non-emoji astral
|
|
});
|
|
|
|
it('leaves BMP text untouched', () => {
|
|
const s = 'Recent Activity ● bugfix — fixed the worker (no surrogates here) ✓ ⚖';
|
|
expect(toBmpSafe(s)).toBe(s);
|
|
});
|
|
|
|
it('output never contains a UTF-16 surrogate code unit', () => {
|
|
const messy = '🔴 a 🟣 b 🔄 c 🦄 d 🎯 e 💬 f ✅ g ⚖️ h 🧠';
|
|
const safe = toBmpSafe(messy);
|
|
expect(hasSurrogate(safe)).toBe(false);
|
|
});
|
|
|
|
it('drops pre-existing lone surrogates', () => {
|
|
const loneHigh = '\uD83D'; // high surrogate with no pair
|
|
expect(toBmpSafe(`x${loneHigh}y`)).toBe('xy');
|
|
});
|
|
|
|
it('handles empty and falsy input', () => {
|
|
expect(toBmpSafe('')).toBe('');
|
|
});
|
|
});
|