Browse Source

Change deprecation warning and fix CI by stubbing console.warn

panr 5 năm trước cách đây
mục cha
commit
7a2311bc8a

+ 5 - 2
packages/ckeditor5-ui/src/labeledinput/labeledinputview.js

@@ -17,7 +17,8 @@ import '../../theme/components/labeledinput/labeledinput.css';
 /**
  * The labeled input view class.
  *
- * @deprecated The component has been marked as deprecated since v18.0.0 and will be removed in v19.0.0.
+ * @deprecated The LabeledInputView component has been marked as deprecated and will be removed in the next major release.
+ * Please use {@link module:ui/labeledfieldview/labeledfieldview~LabeledFieldView} component instead.
  *
  * @extends module:ui/view~View
  */
@@ -32,7 +33,9 @@ export default class LabeledInputView extends View {
 		super( locale );
 
 		// Deprecation warning.
-		console.warn( ' The LabeledInputView component has been marked as deprecated since v18.0.0 and will be removed in v19.0.0. ' );
+		console.warn( 'The LabeledInputView component has been marked as deprecated' +
+			'and will be removed in the next major release.' +
+			'Please use LabeledFieldView component instead.' );
 
 		const inputUid = `ck-input-${ uid() }`;
 		const statusUid = `ck-status-${ uid() }`;

+ 14 - 1
packages/ckeditor5-ui/tests/labeledinput/labeledinputview.js

@@ -3,6 +3,8 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
+/* globals console */
+
 import View from '../../src/view';
 import LabeledInputView from '../../src/labeledinput/labeledinputview';
 import InputView from '../../src/inputtext/inputtextview';
@@ -11,15 +13,26 @@ import LabelView from '../../src/label/labelview';
 describe( 'LabeledInputView', () => {
 	const locale = {};
 
-	let view;
+	let view, deprecatedWarning;
 
 	beforeEach( () => {
+		deprecatedWarning = sinon.stub( console, 'warn' );
 		view = new LabeledInputView( locale, InputView );
 
 		view.render();
 	} );
 
 	describe( 'constructor()', () => {
+		describe( 'deprecation warning', () => {
+			it( 'should be shown in the console after component initialization', () => {
+				sinon.assert.calledOnce( deprecatedWarning );
+			} );
+
+			it( 'should inform about using LabeledFieldView instead of LabeledInputView', () => {
+				sinon.assert.calledWithMatch( deprecatedWarning, 'Please use LabeledFieldView component instead' );
+			} );
+		} );
+
 		it( 'should set view#locale', () => {
 			expect( view.locale ).to.deep.equal( locale );
 		} );