9b395f5cc3
Build Chrome Extension / build (push) Waiting to run
Trigger Website Rebuild (Docs Updated) / dispatch (push) Waiting to run
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
25 lines
950 B
JavaScript
25 lines
950 B
JavaScript
import { describe, expect, it } from 'vitest';
|
|
import { stripHtml } from './text.js';
|
|
|
|
describe('zhihu text helpers', () => {
|
|
it('strips tags and decodes named entities in flat mode', () => {
|
|
expect(stripHtml('<em>Codex</em> & <CLI>')).toBe('Codex & <CLI>');
|
|
});
|
|
|
|
it('decodes decimal and hexadecimal numeric entities', () => {
|
|
expect(stripHtml('"中文" & 'test'')).toBe('"中文" & \'test\'');
|
|
});
|
|
|
|
it('keeps invalid numeric entities unchanged', () => {
|
|
expect(stripHtml('bad � entity')).toBe('bad � entity');
|
|
});
|
|
|
|
it('keeps list excerpts flat by default', () => {
|
|
expect(stripHtml('<p>first</p><br><p>second</p>')).toBe('firstsecond');
|
|
});
|
|
|
|
it('preserves block breaks when requested', () => {
|
|
expect(stripHtml('<p>first</p><br><p>second</p>', { preserveBlocks: true })).toBe('first\n\nsecond');
|
|
});
|
|
});
|