Subagent batch (no bugs found) + markdown: - lotus/avatarDecorations (8): decorationUrl, CDN shape, ALL_DECORATIONS flattening, data invariants (unique category ids + slugs, slug charset). - plugins/call/utils (7): getCallCapabilities — static caps + room/user/device scoped state-keys. - utils/matrix-crypto (3): verifiedDevice via a stubbed CryptoApi. - utils/featureCheck (3): checkIndexedDBSupport success/error/throw paths. - state/typingMembers (8): add/dedup-by-latest-ts/per-room-scope/delete reducer via a jotai store (enableMapSet, mirroring app startup). - plugins/markdown/utils (5): inline + block escape/unescape round-trips. Full suite now 231 tests, all passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
escapeMarkdownInlineSequences,
|
|
unescapeMarkdownInlineSequences,
|
|
escapeMarkdownBlockSequences,
|
|
unescapeMarkdownBlockSequences,
|
|
} from './utils';
|
|
|
|
const identity = (t: string): string => t;
|
|
|
|
test('escapeMarkdownInlineSequences backslash-escapes inline markdown chars', () => {
|
|
assert.equal(escapeMarkdownInlineSequences('a*b'), 'a\\*b');
|
|
assert.equal(escapeMarkdownInlineSequences('under_score'), 'under\\_score');
|
|
// plain text without markdown chars is unchanged
|
|
assert.equal(escapeMarkdownInlineSequences('plain text'), 'plain text');
|
|
});
|
|
|
|
test('inline escape/unescape round-trips', () => {
|
|
for (const s of ['a*b*c', 'under_score', 'plain', 'mix *a* _b_']) {
|
|
assert.equal(unescapeMarkdownInlineSequences(escapeMarkdownInlineSequences(s)), s);
|
|
}
|
|
});
|
|
|
|
test('escapeMarkdownBlockSequences escapes leading block markers', () => {
|
|
assert.equal(escapeMarkdownBlockSequences('# heading', identity), '\\# heading');
|
|
assert.equal(escapeMarkdownBlockSequences('> quote', identity), '\\> quote');
|
|
});
|
|
|
|
test('block unescape passes non-escaped text through processPart', () => {
|
|
assert.equal(unescapeMarkdownBlockSequences('plain', identity), 'plain');
|
|
// a custom processPart is applied to the (non-escaped) text
|
|
assert.equal(
|
|
unescapeMarkdownBlockSequences('plain', (t) => t.toUpperCase()),
|
|
'PLAIN',
|
|
);
|
|
});
|
|
|
|
test('block escape/unescape round-trips', () => {
|
|
for (const s of ['# h', '> quote', 'plain line']) {
|
|
assert.equal(
|
|
unescapeMarkdownBlockSequences(escapeMarkdownBlockSequences(s, identity), identity),
|
|
s,
|
|
);
|
|
}
|
|
});
|