import { Assertions } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { Arr, Obj } from '@ephox/katamari'; import Newlines from 'tinymce/plugins/paste/core/Newlines'; import PastePlugin from 'tinymce/plugins/paste/Plugin'; import Theme from 'tinymce/themes/modern/Theme'; UnitTest.test('tinymce.plugins.paste.browser.NewlinesTest', function () { Theme(); PastePlugin(); // testing Newlines.isPlainText() const textCases = [ { label: 'Basic Chrome markup (including span-wrapped tab)', content: '
a

b
', isText: true }, { label: 'Case shouldn\'t matter', content: '
a

', isText: true }, { label: 'Support all BR types', content: '

', isText: true }, { label: 'Basic IE markup', content: '

a


b

', isText: true }, { label: 'White-space wrapper (Chrome)', content: '
a
', isText: true }, { label: 'White-space wrapper (Chrome) with additional styles', content: '
a
', isText: false }, { label: 'Allowed tag but with attributes qualifies string as not a plain text', content: '
', isText: false } ]; // only DIV,P,BR and SPAN[style="white-space:pre"] tags are allowed in "plain text" string Arr.each('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(','), function (tag) { const content = '

a

<' + tag + '>b

c
d

'; textCases.push({ label: tag.toUpperCase() + ' tag should qualify content (' + content + ') as not a plain text', content, isText: false }); } ); Obj.each(textCases, function (c) { Assertions.assertEq(c.label || 'Asserting: ' + c.content, c.isText, Newlines.isPlainText(c.content)); }); });