import Scroll from '../../../blots/scroll'; describe('Block', function() { it('childless', function() { const scroll = this.initialize(Scroll, ''); const block = scroll.create('block'); block.optimize(); expect(block.domNode).toEqualHTML('
'); }); it('insert into empty', function() { const scroll = this.initialize(Scroll, ''); const block = scroll.create('block'); block.insertAt(0, 'Test'); expect(block.domNode).toEqualHTML('Test'); }); it('insert newlines', function() { const scroll = this.initialize(Scroll, '


'); scroll.insertAt(0, '\n\n\n'); expect(scroll.domNode).toEqualHTML( '





', ); }); it('insert multiline', function() { const scroll = this.initialize(Scroll, '

Hello World!

'); scroll.insertAt(6, 'pardon\nthis\n\ninterruption\n'); expect(scroll.domNode).toEqualHTML(`

Hello pardon

this


interruption

World!

`); }); it('insert into formatted', function() { const scroll = this.initialize(Scroll, '

Welcome

'); scroll.insertAt(3, 'l\n'); expect(scroll.domNode.firstChild.outerHTML).toEqualHTML('

Well

'); expect(scroll.domNode.childNodes[1].outerHTML).toEqualHTML('

come

'); }); it('delete line contents', function() { const scroll = this.initialize(Scroll, '

Hello

World!

'); scroll.deleteAt(0, 5); expect(scroll.domNode).toEqualHTML('


World!

'); }); it('join lines', function() { const scroll = this.initialize(Scroll, '

Hello

World!

'); scroll.deleteAt(5, 1); expect(scroll.domNode).toEqualHTML('

HelloWorld!

'); }); it('join line with empty', function() { const scroll = this.initialize( Scroll, '

HelloWorld


', ); scroll.deleteAt(10, 1); expect(scroll.domNode).toEqualHTML('

HelloWorld

'); }); it('join empty lines', function() { const scroll = this.initialize(Scroll, '



'); scroll.deleteAt(1, 1); expect(scroll.domNode).toEqualHTML('


'); }); it('format empty', function() { const scroll = this.initialize(Scroll, '


'); scroll.formatAt(0, 1, 'header', 1); expect(scroll.domNode).toEqualHTML('


'); }); it('format newline', function() { const scroll = this.initialize(Scroll, '

Hello

'); scroll.formatAt(5, 1, 'header', 2); expect(scroll.domNode).toEqualHTML('

Hello

'); }); it('remove unnecessary break', function() { const scroll = this.initialize(Scroll, '

Test

'); scroll.children.head.domNode.appendChild(document.createElement('br')); scroll.update(); expect(scroll.domNode).toEqualHTML('

Test

'); }); });