import { Assertions } from '@ephox/agar'; import { describe, it } from '@ephox/bedrock-client'; import { Html, SugarElement } from '@ephox/sugar'; import { assert } from 'chai'; import * as PaddingBr from 'tinymce/core/dom/PaddingBr'; describe('browser.tinymce.core.dom.PaddingBrTest', () => { const testRemoveTrailingBr = (label: string, inputHtml: string, expectedHtml: string) => { const elm = SugarElement.fromHtml(inputHtml); PaddingBr.removeTrailingBr(elm); Assertions.assertHtml(label, expectedHtml, Html.getOuter(elm)); }; const testTrimBlockTrailingBr = (label: string, inputHtml: string, expectedHtml: string) => { const elm = SugarElement.fromHtml(inputHtml); PaddingBr.trimBlockTrailingBr(elm); Assertions.assertHtml(label, expectedHtml, Html.getOuter(elm)); }; it('removeTrailingBrs', () => { testRemoveTrailingBr('Should be untouched since it has no brs', '
a
', 'a
'); testRemoveTrailingBr('Should be untouched since the br not at the edge of the tree', 'a
b
a
b
a
b
a
b
a
a
'); testRemoveTrailingBr('Should remove trailing br 2', 'a
a
'); testRemoveTrailingBr('Should remove trailing br 3', 'a
a
'); testRemoveTrailingBr('Should remove trailing br 4', 'a
a
'); testRemoveTrailingBr('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
')), 'Should not be padded'); assert.isFalse(PaddingBr.isPaddedElement(SugarElement.fromHtml('\u00a0\u00a0
')), 'Should not be padded'); assert.isFalse(PaddingBr.isPaddedElement(SugarElement.fromHtml('\u00a0
')), 'Should be padded nbsp'); assert.isTrue(PaddingBr.isPaddedElement(SugarElement.fromHtml('a
a
a
a
a
a