test: lotus decorations, call caps, crypto, featureCheck, typing, markdown (+34)
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>
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
DECORATION_CDN,
|
||||
DECORATION_CATEGORIES,
|
||||
ALL_DECORATIONS,
|
||||
decorationUrl,
|
||||
} from './avatarDecorations';
|
||||
|
||||
test('decorationUrl builds a CDN png url from the slug', () => {
|
||||
assert.equal(decorationUrl('joystick'), `${DECORATION_CDN}/joystick.png`);
|
||||
assert.equal(decorationUrl('lotus_flower'), `${DECORATION_CDN}/lotus_flower.png`);
|
||||
// slug is used verbatim, no encoding/normalisation
|
||||
assert.equal(decorationUrl(''), `${DECORATION_CDN}/.png`);
|
||||
});
|
||||
|
||||
test('DECORATION_CDN is an https url with no trailing slash', () => {
|
||||
assert.match(DECORATION_CDN, /^https:\/\//);
|
||||
assert.equal(DECORATION_CDN.endsWith('/'), false);
|
||||
});
|
||||
|
||||
test('ALL_DECORATIONS is the flattened set of every category decoration', () => {
|
||||
const expectedCount = DECORATION_CATEGORIES.reduce((n, c) => n + c.decorations.length, 0);
|
||||
assert.equal(ALL_DECORATIONS.length, expectedCount);
|
||||
|
||||
// every decoration in a category is present (by reference) in ALL_DECORATIONS
|
||||
DECORATION_CATEGORIES.forEach((category) => {
|
||||
category.decorations.forEach((decoration) => {
|
||||
assert.ok(ALL_DECORATIONS.includes(decoration));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('every category has a non-empty id, label and decorations list', () => {
|
||||
DECORATION_CATEGORIES.forEach((category) => {
|
||||
assert.equal(typeof category.id, 'string');
|
||||
assert.ok(category.id.length > 0);
|
||||
assert.equal(typeof category.label, 'string');
|
||||
assert.ok(category.label.length > 0);
|
||||
assert.ok(Array.isArray(category.decorations));
|
||||
assert.ok(category.decorations.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('category ids are unique', () => {
|
||||
const ids = DECORATION_CATEGORIES.map((c) => c.id);
|
||||
assert.equal(new Set(ids).size, ids.length);
|
||||
});
|
||||
|
||||
test('every decoration slug is unique across all categories', () => {
|
||||
const slugs = ALL_DECORATIONS.map((d) => d.slug);
|
||||
assert.equal(new Set(slugs).size, slugs.length);
|
||||
});
|
||||
|
||||
test('every decoration has a non-empty slug and name', () => {
|
||||
ALL_DECORATIONS.forEach((decoration) => {
|
||||
assert.equal(typeof decoration.slug, 'string');
|
||||
assert.ok(decoration.slug.length > 0);
|
||||
assert.equal(typeof decoration.name, 'string');
|
||||
assert.ok(decoration.name.length > 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('slugs use the snake_case charset (lowercase, digits, underscore)', () => {
|
||||
ALL_DECORATIONS.forEach((decoration) => {
|
||||
assert.match(decoration.slug, /^[a-z0-9_]+$/, `bad slug: ${decoration.slug}`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user