Browse Source

Added tests for added warning.

Kuba Niegowski 5 years ago
parent
commit
f97481d136

+ 16 - 0
packages/ckeditor5-engine/tests/model/text.js

@@ -3,8 +3,11 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/* globals console */
+
 import Text from '../../src/model/text';
 import Node from '../../src/model/node';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'Text', () => {
 	describe( 'constructor()', () => {
@@ -35,6 +38,8 @@ describe( 'Text', () => {
 	describe( 'is()', () => {
 		let text;
 
+		testUtils.createSinonSandbox();
+
 		before( () => {
 			text = new Text( 'bar' );
 		} );
@@ -53,6 +58,17 @@ describe( 'Text', () => {
 			expect( text.is( 'rootElement' ) ).to.be.false;
 			expect( text.is( 'documentFragment' ) ).to.be.false;
 		} );
+
+		it( 'should print warning for legacy "text" argument', () => {
+			testUtils.sinon.stub( console, 'warn' );
+
+			expect( text.is( 'text' ) ).to.be.false;
+
+			sinon.assert.calledOnce( console.warn );
+			sinon.assert.calledWithExactly( console.warn,
+				sinon.match( /^model-text-node-deprecated-is-text-argument/ )
+			);
+		} );
 	} );
 
 	describe( '_clone()', () => {

+ 16 - 0
packages/ckeditor5-engine/tests/model/textproxy.js

@@ -3,12 +3,15 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/* globals console */
+
 import Element from '../../src/model/element';
 import Text from '../../src/model/text';
 import TextProxy from '../../src/model/textproxy';
 import Model from '../../src/model/model';
 
 import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'TextProxy', () => {
 	let model, doc, element, textProxy, root, textProxyNoParent, text, textNoParent;
@@ -98,6 +101,8 @@ describe( 'TextProxy', () => {
 	} );
 
 	describe( 'is()', () => {
+		testUtils.createSinonSandbox();
+
 		it( 'should return true for $textProxy', () => {
 			expect( textProxy.is( '$textProxy' ) ).to.be.true;
 			expect( textProxy.is( 'model:$textProxy' ) ).to.be.true;
@@ -112,6 +117,17 @@ describe( 'TextProxy', () => {
 			expect( textProxy.is( 'documentFragment' ) ).to.be.false;
 			expect( textProxy.is( 'rootElement' ) ).to.be.false;
 		} );
+
+		it( 'should print warning for legacy "textProxy" argument', () => {
+			testUtils.sinon.stub( console, 'warn' );
+
+			expect( textProxy.is( 'textProxy' ) ).to.be.false;
+
+			sinon.assert.calledOnce( console.warn );
+			sinon.assert.calledWithExactly( console.warn,
+				sinon.match( /^model-textProxy-deprecated-is-textProxy-argument/ )
+			);
+		} );
 	} );
 
 	describe( 'getPath', () => {

+ 16 - 0
packages/ckeditor5-engine/tests/view/text.js

@@ -3,10 +3,13 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/* globals console */
+
 import Node from '../../src/view/node';
 import Text from '../../src/view/text';
 import Document from '../../src/view/document';
 import { StylesProcessor } from '../../src/view/stylesmap';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'Text', () => {
 	let document;
@@ -28,6 +31,8 @@ describe( 'Text', () => {
 	describe( 'is()', () => {
 		let text;
 
+		testUtils.createSinonSandbox();
+
 		before( () => {
 			text = new Text( document, 'foo' );
 		} );
@@ -53,6 +58,17 @@ describe( 'Text', () => {
 			expect( text.is( 'model:$text' ) ).to.be.false;
 			expect( text.is( 'model:node' ) ).to.be.false;
 		} );
+
+		it( 'should print warning for legacy "text" argument', () => {
+			testUtils.sinon.stub( console, 'warn' );
+
+			expect( text.is( 'text' ) ).to.be.false;
+
+			sinon.assert.calledOnce( console.warn );
+			sinon.assert.calledWithExactly( console.warn,
+				sinon.match( /^view-text-node-deprecated-is-text-argument/ )
+			);
+		} );
 	} );
 
 	describe( '_clone()', () => {

+ 16 - 0
packages/ckeditor5-engine/tests/view/textproxy.js

@@ -3,6 +3,8 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/* globals console */
+
 import TextProxy from '../../src/view/textproxy';
 import Text from '../../src/view/text';
 import ContainerElement from '../../src/view/containerelement';
@@ -13,6 +15,7 @@ import createDocumentMock from '../../tests/view/_utils/createdocumentmock';
 import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import Document from '../../src/view/document';
 import { StylesProcessor } from '../../src/view/stylesmap';
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
 
 describe( 'TextProxy', () => {
 	let text, parent, wrapper, textProxy, document;
@@ -65,6 +68,8 @@ describe( 'TextProxy', () => {
 	} );
 
 	describe( 'is()', () => {
+		testUtils.createSinonSandbox();
+
 		it( 'should return true for $textProxy', () => {
 			expect( textProxy.is( '$textProxy' ) ).to.be.true;
 			expect( textProxy.is( 'view:$textProxy' ) ).to.be.true;
@@ -84,6 +89,17 @@ describe( 'TextProxy', () => {
 			expect( textProxy.is( 'documentFragment' ) ).to.be.false;
 			expect( textProxy.is( 'model:$textProxy' ) ).to.be.false;
 		} );
+
+		it( 'should print warning for legacy "textProxy" argument', () => {
+			testUtils.sinon.stub( console, 'warn' );
+
+			expect( textProxy.is( 'textProxy' ) ).to.be.false;
+
+			sinon.assert.calledOnce( console.warn );
+			sinon.assert.calledWithExactly( console.warn,
+				sinon.match( /^view-textProxy-deprecated-is-textProxy-argument/ )
+			);
+		} );
 	} );
 
 	describe( 'offsetSize', () => {