import assert from 'node:assert/strict';
import test from 'node:test';
import { redactContent, scanContent } from './mindspace-content-scan.mjs';
test('scanContent warns on phone numbers', () => {
const result = scanContent('联系电话 13800138000');
assert.equal(result.status, 'warned');
assert.equal(result.allowed, true);
assert.equal(result.findings[0].type, 'phone');
});
test('scanContent ignores trusted google font hosts', () => {
const result = scanContent(
"@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC&display=swap');",
);
assert.equal(result.findings.length, 0);
assert.equal(result.allowed, true);
});
test('scanContent blocks id cards', () => {
const result = scanContent('身份证 11010119900307888X');
assert.equal(result.status, 'blocked');
assert.equal(result.allowed, false);
});
test('scanContent blocks html active content and private references', () => {
const result = scanContent(
'x',
{ format: 'html' },
);
assert.equal(result.allowed, false);
assert.deepEqual(
result.findings.map((finding) => finding.type),
['html_script', 'html_javascript_url', 'private_resource_reference'],
);
});
test('scanContent can allow active html as acknowledgeable publication warnings', () => {
const result = scanContent(
'',
{ format: 'html', allowHtmlActiveContent: true },
);
assert.equal(result.status, 'warned');
assert.equal(result.allowed, true);
assert.deepEqual(
result.findings.map((finding) => [finding.type, finding.blocking]),
[
['html_script', false],
['html_inline_handler', false],
],
);
});
test('scanContent can allow interactive html forms as acknowledgeable warnings', () => {
const result = scanContent(
'