import test from 'node:test'; import assert from 'node:assert/strict'; import { plainText } from '../src/html-text.js'; test('inline image emoji preserve the exact text order and wrapper titles do not duplicate them', () => { const html = '

ε₯½πŸ‘ε‘€πŸ˜€

'; assert.equal(plainText(html), 'ε₯½πŸ‘ε‘€πŸ˜€'); }); test('emoji-only and non-Unicode emoticon alt spellings remain readable', () => { assert.equal(plainText('

πŸ˜€

'), 'πŸ˜€'); assert.equal(plainText('(laugh)'), '(laugh)'); assert.equal(plainText('  '), 'ζŒ₯手'); assert.equal(plainText(''), '[图片]'); }); test('numeric entities, named entities, variation selectors, joiners and skin tones are preserved', () => { const html = '

A B👩🏽‍💻👍🏼❀️♥

'; assert.equal(plainText(html), 'A\u00a0BπŸ‘©πŸ½β€πŸ’»πŸ‘πŸΌβ€οΈβ™₯'); }); test('HTML attributes containing greater-than signs and nested markup parse without losing text', () => { assert.equal(plainText('

beforeA > Bafter

next
line
'), 'beforeA > Bafter\nnext\nline'); assert.equal(plainText('

Unclosed formattingπŸ˜€'), 'Unclosed formattingπŸ˜€'); }); test('scripts, styles, templates and comments never become body text or execute', () => { globalThis.__teamsFictionalHtmlExecution = false; try { assert.equal(plainText('πŸ˜€'), 'πŸ˜€'); assert.equal(globalThis.__teamsFictionalHtmlExecution, false); } finally { delete globalThis.__teamsFictionalHtmlExecution; } }); test('unknown image placeholders and bounded labels never expose image URLs or split surrogate pairs', () => { const content = plainText('' + 'πŸ˜€'.repeat(250) + ''); assert.equal(content, '[图片]' + 'πŸ˜€'.repeat(200)); assert.doesNotMatch(content, /https:|private-id|\uFFFD/); }); test('plain text, literal entity text and ordinary blank input remain supported', () => { assert.equal(plainText('Plain & text'), 'Plain & text'); assert.equal(plainText('

<safe> & friends.

'), ' & friends.'); assert.equal(plainText('


'), ''); assert.equal(plainText(null), ''); });