Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #549 from ckeditor/i/6110-deprecate-labeledinputview
Browse files Browse the repository at this point in the history
Other: `LabeledInputView` component has been marked as deprecated in favour of use `LabeledFieldView` component instead. See ckeditor/ckeditor5#6110.
  • Loading branch information
jodator authored Mar 26, 2020
2 parents c5f7e82 + bc063b9 commit ae08076
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/labeledinput/labeledinputview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand All @@ -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() }`;

Expand Down
19 changes: 18 additions & 1 deletion tests/labeledinput/labeledinputview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 );
} );
Expand Down

0 comments on commit ae08076

Please sign in to comment.