import { Assertions, GeneralSteps, Logger, Pipeline, Step } from '@ephox/agar'; import { Element, Html } from '@ephox/sugar'; import PaddingBr from 'tinymce/core/dom/PaddingBr'; import { UnitTest } from '@ephox/bedrock'; UnitTest.asynctest('browser.tinymce.core.dom.PaddingBrTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; const sTestRemoveTrailingBr = function (label, inputHtml, expectedHtml) { return Step.sync(function () { const elm = Element.fromHtml(inputHtml); PaddingBr.removeTrailingBr(elm); Assertions.assertHtml(label, expectedHtml, Html.getOuter(elm)); }); }; const sTestTrimBlockTrailingBr = function (label, inputHtml, expectedHtml) { return Step.sync(function () { const elm = Element.fromHtml(inputHtml); PaddingBr.trimBlockTrailingBr(elm); Assertions.assertHtml(label, expectedHtml, Html.getOuter(elm)); }); }; Pipeline.async({}, [ Logger.t('removeTrailingBrs', GeneralSteps.sequence([ sTestRemoveTrailingBr('Should be untouched since it has no brs', '
a
', 'a
'), sTestRemoveTrailingBr('Should be untouched since the br not at the edge of the tree', 'a
b
a
b
a
b
a
b
a
a
'), sTestRemoveTrailingBr('Should remove trailing br 2', 'a
a
'), sTestRemoveTrailingBr('Should remove trailing br 3', 'a
a
'), sTestRemoveTrailingBr('Should remove trailing br 4', 'a
a
'), sTestRemoveTrailingBr('Should be untouched since there is more than one br', 'a
a
a
a
a
'); PaddingBr.fillWithPaddingBr(elm); Assertions.assertHtml('Should be padded with bogus br', 'a
'))); Assertions.assertEq('Should not be padded', false, PaddingBr.isPaddedElement(Element.fromHtml('\u00a0\u00a0
'))); Assertions.assertEq('Should not be padded', false, PaddingBr.isPaddedElement(Element.fromHtml('\u00a0
'))); Assertions.assertEq('Should be padded br', true, PaddingBr.isPaddedElement(Element.fromHtml('a
a
a
a
a
a