From 82fe2a5f001e7dfd1a09de9721ae232b718d9121 Mon Sep 17 00:00:00 2001 From: panr Date: Mon, 23 Mar 2020 17:18:53 +0100 Subject: [PATCH] Deprecate LabeledInputView --- src/labeledinput/labeledinputview.js | 10 ++++++++++ tests/labeledinput/labeledinputview.js | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/labeledinput/labeledinputview.js b/src/labeledinput/labeledinputview.js index c94d2e12..c5168c2a 100644 --- a/src/labeledinput/labeledinputview.js +++ b/src/labeledinput/labeledinputview.js @@ -7,6 +7,8 @@ * @module ui/labeledinput/labeledinputview */ +/* globals console */ + import View from '../view'; import uid from '@ckeditor/ckeditor5-utils/src/uid'; import LabelView from '../label/labelview'; @@ -15,6 +17,9 @@ import '../../theme/components/labeledinput/labeledinput.css'; /** * The labeled input view class. * + * @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 */ export default class LabeledInputView extends View { @@ -27,6 +32,11 @@ export default class LabeledInputView extends View { constructor( locale, InputView ) { super( locale ); + // Deprecation warning. + 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() }`; diff --git a/tests/labeledinput/labeledinputview.js b/tests/labeledinput/labeledinputview.js index 68751490..03782c67 100644 --- a/tests/labeledinput/labeledinputview.js +++ b/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,30 @@ 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(); } ); + afterEach( () => { + sinon.restore(); + } ); + 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 ); } );