Files
memind/plaza-posts.test.mjs
T
john 229805a070 Improve WeChat MP replies and ship MindSpace/H5 production updates.
Add WeChat service account routing with sync acks, connectivity tests, and context isolation; document deploy runbooks; and bundle related MindSpace, voice, Plaza, and server gateway changes for production rollout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-19 23:06:43 +08:00

34 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { mapPlazaError, plazaInternals } from './plaza-posts.mjs';
test('normalizeTags trims, dedupes by order, and caps at five', () => {
assert.deepEqual(plazaInternals.normalizeTags([' a ', 'b', '', 'c', 'd', 'e', 'f']), [
'a',
'b',
'c',
'd',
'e',
]);
});
test('clampLimit enforces defaults and maximum', () => {
assert.equal(plazaInternals.clampLimit(undefined), 20);
assert.equal(plazaInternals.clampLimit(999), 50);
assert.equal(plazaInternals.clampLimit(0), 20);
});
test('normalizeSort accepts recommend, hot, or new', () => {
assert.equal(plazaInternals.normalizeSort(undefined), 'recommend');
assert.equal(plazaInternals.normalizeSort('new'), 'new');
assert.equal(plazaInternals.normalizeSort('hot'), 'hot');
assert.equal(plazaInternals.normalizeSort('recommended'), 'recommend');
});
test('mapPlazaError maps documented API codes', () => {
assert.equal(mapPlazaError({ code: 'ALREADY_PUBLISHED' }), 409);
assert.equal(mapPlazaError({ code: 'PUBLICATION_NOT_ONLINE' }), 422);
assert.equal(mapPlazaError({ code: 'POST_PERMISSION_DENIED' }), 403);
assert.equal(mapPlazaError({ code: 'unknown' }), 500);
});