/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages-internal/api-docs-builder/src/utils/escapeCell.test.ts
52 строки
2 KB
Brijesh Bittu
[docs-infra] Rename package to @mui/internal-api-docs-builder (#48230)
21 апр 2026, 12:17
Не верифицирован
21 апр 2026, 12:17
c11f4ee
Код
Авторство
О чём код?
import { expect } from 'chai'; import escapeCell from './escapeCell'; describe('escapeCell', () => { it('escapes pipes outside backticks', () => { const input = 'true | false'; const result = escapeCell(input); expect(result).to.equal('true \\| false'); }); it('does not escape pipes inside single backticks', () => { const input = '`true | false`'; const result = escapeCell(input); expect(result).to.equal('`true | false`'); }); it('does not escape pipes inside multiple inline code spans', () => { const input = 'Use `a | b` and `x | y` here'; const result = escapeCell(input); expect(result).to.equal('Use `a | b` and `x | y` here'); }); it('escapes pipes in normal text but not inside backticks', () => { const input = '`a | b` or c | d'; const result = escapeCell(input); expect(result).to.equal('`a | b` or c \\| d'); }); it('handles strings without any pipes', () => { const input = 'no pipes here'; const result = escapeCell(input); expect(result).to.equal('no pipes here'); }); it('keeps < inside code spans but escapes outside', () => { const input = 'Use <b>bold</b> and `<div>` tags'; const result = escapeCell(input); expect(result).to.equal('Use <b>bold</b> and `<div>` tags'); }); it('does not escape pipe at string start or end inside backticks', () => { const input = '`| start and end |`'; const result = escapeCell(input); expect(result).to.equal('`| start and end |`'); }); it('escapes pipe at string start or end outside backticks', () => { const input = '| start | and end |'; const result = escapeCell(input); expect(result).to.equal('\\| start \\| and end \\|'); }); });