suite.test('hasContent', function () { setupHtml('<span contentEditable="false">1</span>'); const caretContainerBlock = CaretContainer.insertBlock('p', getRoot().firstChild, true); LegacyUnit.equal(CaretContainer.hasContent(caretContainerBlock), false); caretContainerBlock.insertBefore(document.createTextNode('a'), caretContainerBlock.firstChild); LegacyUnit.equal(CaretContainer.hasContent(caretContainerBlock), true); });
suite.test('showCaretContainerBlock', function () { setupHtml('<span contentEditable="false">1</span>'); const caretContainerBlock = CaretContainer.insertBlock('p', getRoot().firstChild, true); caretContainerBlock.insertBefore(document.createTextNode('a'), caretContainerBlock.firstChild); CaretContainer.showCaretContainerBlock(caretContainerBlock); LegacyUnit.equal(caretContainerBlock.outerHTML, '<p>a</p>'); });
Step.sync(function () { setupHtml('<span contentEditable="false">1</span><span contentEditable="false">2</span>'); CaretContainer.insertBlock('p', getRoot().childNodes[1], true); Assertions.assertEq('Should be block container', true, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1])); const pos = CaretContainerRemove.removeAndReposition(getRoot().childNodes[1], new CaretPosition(getRoot(), 3)); Assertions.assertEq('Should be changed offset', 2, pos.offset()); Assertions.assertDomEq('Should be unchanged container', Element.fromDom(getRoot()), Element.fromDom(pos.container())); Assertions.assertEq('Should not be block container', false, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1])); })
suite.test('insertBlock after element', function () { setupHtml('<span contentEditable="false">1</span>'); LegacyUnit.equalDom(CaretContainer.insertBlock('p', getRoot().firstChild, false), getRoot().lastChild); LegacyUnit.equal(CaretContainer.isCaretContainerBlock(getRoot().lastChild), true); });
suite.test('insertInline between elements', function () { setupHtml('<span contentEditable="false">1</span><span contentEditable="false">1</span>'); LegacyUnit.equalDom(CaretContainer.insertBlock('p', getRoot().lastChild, true), getRoot().childNodes[1]); LegacyUnit.equal(CaretContainer.isCaretContainerBlock(getRoot().childNodes[1]), true); });