Files
ssh-portfolio/test/content-policy.test.js
T

16 lines
693 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { safeName, validatePost } from '../src/content-policy.js';
test('bulletin posts normalize whitespace and reject terminal controls', () => {
assert.deepEqual(validatePost(' hello world '), { ok: true, value: 'hello world' });
assert.match(validatePost('hello\u001b[2J').reason, /unsupported/);
});
test('bulletin posts reject emoji and excessive length', () => {
assert.match(validatePost('hello 😀').reason, /Emoji/);
assert.match(validatePost('x'.repeat(181)).reason, /limited/);
});
test('names are reduced to safe display characters', () => assert.equal(safeName('\u001b[31m bob!!'), '31mbob'));