import { describe, expect, it } from 'vitest';
|
|
import { formatFormLabel } from './formLabel';
|
|
describe('formatFormLabel', () => {
|
it('converts both configured line-break markers', () => {
|
expect(formatFormLabel(String.raw`部门\nDepartment<\n>名称`)).toBe('部门\nDepartment\n名称');
|
});
|
|
it('converts escaped newlines and br tags without interpreting other markup', () => {
|
expect(formatFormLabel(String.raw`中文\\nEnglish`)).toBe('中文\nEnglish');
|
expect(formatFormLabel(String.raw`中文\\\nEnglish`)).toBe('中文\nEnglish');
|
expect(formatFormLabel(String.raw`中文<br>English`)).toBe('中文\nEnglish');
|
expect(formatFormLabel(String.raw`中文\<BR />English`)).toBe('中文\nEnglish');
|
expect(formatFormLabel(String.raw`中文<b>English</b>`)).toBe('中文<b>English</b>');
|
});
|
|
it('preserves actual line breaks and renders other markup as text', () => {
|
expect(formatFormLabel('申请人\n<b>Applicant</b>')).toBe('申请人\n<b>Applicant</b>');
|
expect(formatFormLabel(undefined)).toBe('');
|
});
|
});
|