import { Assert, describe, it } from '@ephox/bedrock-client'; import { Arr } from '@ephox/katamari'; import type { SugarElement } from 'ephox/sugar/api/node/SugarElement'; import * as SugarFragment from 'ephox/sugar/api/node/SugarFragment'; import * as SugarNode from 'ephox/sugar/api/node/SugarNode'; import * as Attribute from 'ephox/sugar/api/properties/Attribute'; import * as TextContent from 'ephox/sugar/api/properties/TextContent'; import * as Traverse from 'ephox/sugar/api/search/Traverse'; describe('browser.sugar.node.SugarFragmentTest', () => { it('TINY-13526: should return fragment', () => { const html = '
Paragraph 1
Paragraph 2

unclosed'; const fragment = SugarFragment.fromHtml(html); const children = Traverse.children(fragment); Assert.eq('Should still create fragment', children.length > 0, true); const firstChild = children[0]; Assert.eq('First child should be div', SugarNode.name(firstChild), 'div'); const nestedChildren = Traverse.children(firstChild); Assert.eq('Div should have 1 child', nestedChildren.length, 1); Assert.eq('Nested child should be p', SugarNode.name(nestedChildren[0]), 'p'); Assert.eq('Paragraph content should match', TextContent.get(nestedChildren[0]), 'unclosed'); }); it('TINY-13526: should handle script tags', () => { const html = '