|
|
@@ -17,6 +17,7 @@ import { parse } from '../../src/dev-utils/view';
|
|
|
import { INLINE_FILLER, INLINE_FILLER_LENGTH, isBlockFiller, BR_FILLER } from '../../src/view/filler';
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
import createElement from '@ckeditor/ckeditor5-utils/src/dom/createelement';
|
|
|
+import log from '@ckeditor/ckeditor5-utils/src/log';
|
|
|
|
|
|
testUtils.createSinonSandbox();
|
|
|
|
|
|
@@ -1355,7 +1356,11 @@ describe( 'Renderer', () => {
|
|
|
describe( 'similar selection', () => {
|
|
|
// Use spies to check selection updates. Some selection positions are not achievable in some
|
|
|
// browsers (e.g. <p>Foo<b>{}Bar</b></p> in Chrome) so asserting dom selection after rendering would fail.
|
|
|
- let selectionCollapseSpy, selectionExtendSpy;
|
|
|
+ let selectionCollapseSpy, selectionExtendSpy, logWarnStub;
|
|
|
+
|
|
|
+ before( () => {
|
|
|
+ logWarnStub = sinon.stub( log, 'warn' );
|
|
|
+ } );
|
|
|
|
|
|
afterEach( () => {
|
|
|
if ( selectionCollapseSpy ) {
|
|
|
@@ -1367,6 +1372,11 @@ describe( 'Renderer', () => {
|
|
|
selectionExtendSpy.restore();
|
|
|
selectionExtendSpy = null;
|
|
|
}
|
|
|
+ logWarnStub.reset();
|
|
|
+ } );
|
|
|
+
|
|
|
+ after( () => {
|
|
|
+ logWarnStub.restore();
|
|
|
} );
|
|
|
|
|
|
it( 'should always render collapsed selection even if it is similar', () => {
|
|
|
@@ -1405,6 +1415,7 @@ describe( 'Renderer', () => {
|
|
|
expect( selectionCollapseSpy.calledWith( domB.childNodes[ 0 ], 0 ) ).to.true;
|
|
|
expect( selectionExtendSpy.calledOnce ).to.true;
|
|
|
expect( selectionExtendSpy.calledWith( domB.childNodes[ 0 ], 0 ) ).to.true;
|
|
|
+ expect( logWarnStub.notCalled ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should always render collapsed selection even if it is similar (with empty element)', () => {
|
|
|
@@ -1442,6 +1453,7 @@ describe( 'Renderer', () => {
|
|
|
expect( selectionCollapseSpy.calledWith( domP.childNodes[ 0 ], 3 ) ).to.true;
|
|
|
expect( selectionExtendSpy.calledOnce ).to.true;
|
|
|
expect( selectionExtendSpy.calledWith( domP.childNodes[ 0 ], 3 ) ).to.true;
|
|
|
+ expect( logWarnStub.notCalled ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should always render non-collapsed selection if it not is similar', () => {
|
|
|
@@ -1480,6 +1492,7 @@ describe( 'Renderer', () => {
|
|
|
expect( selectionCollapseSpy.calledWith( domP.childNodes[ 0 ], 2 ) ).to.true;
|
|
|
expect( selectionExtendSpy.calledOnce ).to.true;
|
|
|
expect( selectionExtendSpy.calledWith( domB.childNodes[ 0 ], 1 ) ).to.true;
|
|
|
+ expect( logWarnStub.notCalled ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should not render non-collapsed selection it is similar (element start)', () => {
|
|
|
@@ -1516,6 +1529,7 @@ describe( 'Renderer', () => {
|
|
|
|
|
|
expect( selectionCollapseSpy.notCalled ).to.true;
|
|
|
expect( selectionExtendSpy.notCalled ).to.true;
|
|
|
+ expect( logWarnStub.called ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should not render non-collapsed selection it is similar (element end)', () => {
|
|
|
@@ -1552,6 +1566,7 @@ describe( 'Renderer', () => {
|
|
|
|
|
|
expect( selectionCollapseSpy.notCalled ).to.true;
|
|
|
expect( selectionExtendSpy.notCalled ).to.true;
|
|
|
+ expect( logWarnStub.called ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should not render non-collapsed selection it is similar (element start - nested)', () => {
|
|
|
@@ -1588,6 +1603,7 @@ describe( 'Renderer', () => {
|
|
|
|
|
|
expect( selectionCollapseSpy.notCalled ).to.true;
|
|
|
expect( selectionExtendSpy.notCalled ).to.true;
|
|
|
+ expect( logWarnStub.called ).to.true;
|
|
|
} );
|
|
|
|
|
|
it( 'should not render non-collapsed selection it is similar (element end - nested)', () => {
|
|
|
@@ -1623,6 +1639,7 @@ describe( 'Renderer', () => {
|
|
|
|
|
|
expect( selectionCollapseSpy.notCalled ).to.true;
|
|
|
expect( selectionExtendSpy.notCalled ).to.true;
|
|
|
+ expect( logWarnStub.called ).to.true;
|
|
|
} );
|
|
|
} );
|
|
|
} );
|