/** * Typing.spec.js * (c) 2015~ Summernote Team * summernote may be freely distributed under the MIT license./ */ /* jshint unused: false */ /* jshint -W101 */ import chai from 'chai'; import $ from 'jquery'; import range from '../../../../src/js/base/core/range'; import Typing from '../../../../src/js/base/editing/Typing'; var expect = chai.expect; describe('base:editing.Style', () => { function typing(level) { return new Typing({ options: { blockquoteBreakingLevel: level } }); } describe('base:editing.Typing', () => { describe('insertParagraph', () => { describe('blockquote breaking support', () => { var $editable; function check(html) { expect($editable.html()).to.equalsIgnoreCase(html); } beforeEach(() => { $editable = $('
Part1
Part2.1
Part2.2
Part3
'); }); it('should not break blockquote if blockquoteBreakingLevel=0', () => { typing(0).insertParagraph($editable, range.create($('#2', $editable)[0].firstChild, 1)); check('
Part1

P

art2.1
Part2.2

Part3
'); }); it('should break the first blockquote if blockquoteBreakingLevel=1', () => { typing(1).insertParagraph($editable, range.create($('#2', $editable)[0].firstChild, 1)); check('
Part1

P


art2.1
Part2.2

Part3
'); }); it('should break all blockquotes if blockquoteBreakingLevel=2', () => { typing(2).insertParagraph($editable, range.create($('#2', $editable)[0].firstChild, 1)); check('
Part1

P


art2.1
Part2.2

Part3
'); }); it('should remove leading BR from split, when breaking is on the right edge of a line', () => { typing(1).insertParagraph($editable, range.create($('#2', $editable)[0].firstChild, 7)); check('
Part1

Part2.1


Part2.2

Part3
'); }); it('should insert new paragraph after the blockquote, if break happens at the end of the blockquote', () => { typing(2).insertParagraph($editable, range.create($('#1', $editable)[0].lastChild, 5)); check('

Part1

Part2.1
Part2.2
Part3


'); }); it('should insert new paragraph before the blockquote, if break happens at the beginning of the blockquote', () => { typing(2).insertParagraph($editable, range.create($('#1', $editable)[0].firstChild, 0)); check('


Part1

Part2.1
Part2.2
Part3

'); }); }); }); }); });