import { Assert, UnitTest } from '@ephox/bedrock-client'; import { Arr } from '@ephox/katamari'; import { Html, Insert, Remove, SugarBody, SugarElement } from '@ephox/sugar'; import * as TableContent from 'ephox/snooker/api/TableContent'; UnitTest.test('TableMergeContentTest', () => { const mergeContentTest = (specs: { label: string; html: string; expected: string }[]) => { const table = SugarElement.fromTag('table'); const row = SugarElement.fromTag('tr'); Insert.append(table, row); const cells = Arr.map(specs, (item) => { const cell = SugarElement.fromTag('td'); cell.dom.innerHTML = item.html; Insert.append(row, cell); return cell; }); Insert.append(SugarBody.body(), table); TableContent.merge(cells); Arr.each(specs, (spec, i) => { Assert.eq(() => spec.label + ' expected:\n' + spec.expected + '\n got: \n' + Html.get(cells[i]), spec.expected, Html.get(cells[i])); }); Remove.remove(table); }; /* Todo: - feff chars should not breaketh - add \r \n chars after block tags ? */ const spec1 = [ { label: 'just a P block tag, there should NOT be a br proceeding it', html: '
There should not be a br after.
', expected: 'There should not be a br after.
Standard paragraph
' + ' I am a textnode and should have a br after the period.
deep para
Standard paragraph
I am a textnode and should have a br after the period.', expected: '' }, { label: 'img tag, with a textnode after, there SHOULD be a br proceeding it', html: '
',
expected: ''
},
{
label: 'nested, with a textnode after, there SHOULD be a br proceeding it',
html: 'deep para
There should not be a br after.
', expected: 'standard issue textnodeThere should not be a br after.
I am inline textnode
I am inline textnode',
expected: ''
},
{
label: ' = Gotach test = tricky textnode with an empty block tag',
html: 'textnode with empty block tag ',
expected: ''
},
{
label: 'brs should NOT have more br appended',
html: '
',
expected: '