import { describe, it } from '@ephox/bedrock-client';
import { Arr } from '@ephox/katamari';
import { assert } from 'chai';
import * as Newlines from 'tinymce/core/paste/Newlines';
describe('atomic.tinymce.core.paste.NewlinesTest', () => {
it('isPlainText is true for text content', () => {
Arr.each([
{
label: 'Basic Chrome markup (including span-wrapped tab)',
content: '
a
b
',
},
{
label: `Case shouldn't matter`,
content: 'a
',
},
{
label: 'Support all BR types',
content: '
',
},
{
label: 'Basic IE markup',
content: 'a
b
',
},
{
label: 'White-space wrapper (Chrome)',
content: ' a
',
}
], (c) => {
assert.isTrue(Newlines.isPlainText(c.content), c.label);
});
});
it('only DIV,P,BR and SPAN[style="white-space:pre"] tags are allowed in "plain text" string', () => {
Arr.each([
{
label: 'White-space wrapper (Chrome) with additional styles is not plain text',
content: ' a
',
},
{
label: 'Allowed tag but with attributes qualifies string as not plain text',
content: '
',
},
...Arr.map(('a,abbr,address,article,aside,audio,b,bdi,bdo,blockquote,button,cite,' +
'code,del,details,dfn,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,' +
'h4,h5,h6,header,hgroup,hr,i,ins,label,menu,nav,noscript,object,ol,pre,' +
'q,s,script,section,select,small,strong,style,sub,sup,svg,table,textarea,' +
'time,u,ul,var,video,wbr').split(','), (tag) => {
const content = `a
<${tag}>b${tag}>c
d
`;
return {
label: `${tag.toUpperCase()} tag should qualify content (${content}) as not plain text`,
content
};
})
], (c) => {
assert.isFalse(Newlines.isPlainText(c.content), c.label);
});
});
});