8
0
Просмотр исходного кода

Tests: Added missing tests for createLabeledInputText().

Aleksander Nowodzinski 5 лет назад
Родитель
Сommit
670bc95664

+ 1 - 2
packages/ckeditor5-ui/src/labeledfield/utils.js

@@ -52,8 +52,7 @@ export function createLabeledInputText( labeledFieldView, viewUid, statusUid ) {
 		labeledFieldView.errorText = null;
 	} );
 
-	// TODO
-	labeledFieldView.bind( 'isEmpty', 'isFocused', 'hasError', 'placeholder' ).to( inputView );
+	labeledFieldView.bind( 'isEmpty', 'isFocused', 'placeholder' ).to( inputView );
 
 	return inputView;
 }

+ 24 - 0
packages/ckeditor5-ui/tests/labeledfield/utils.js

@@ -64,6 +64,30 @@ describe( 'LabeledFieldView utils', () => {
 			expect( labeledInput.fieldView.hasError ).to.be.false;
 		} );
 
+		it( 'should bind labeledInput#isEmpty to input\'s #isEmpty', () => {
+			labeledInput.fieldView.isEmpty = true;
+			expect( labeledInput.isEmpty ).to.be.true;
+
+			labeledInput.fieldView.isEmpty = false;
+			expect( labeledInput.isEmpty ).to.be.false;
+		} );
+
+		it( 'should bind labeledInput#isFocused to input\'s #isFocused', () => {
+			labeledInput.fieldView.isFocused = true;
+			expect( labeledInput.isFocused ).to.be.true;
+
+			labeledInput.fieldView.isFocused = false;
+			expect( labeledInput.isFocused ).to.be.false;
+		} );
+
+		it( 'should bind labeledInput#placeholder to input\'s #placeholder', () => {
+			labeledInput.fieldView.placeholder = null;
+			expect( labeledInput.placeholder ).to.be.null;
+
+			labeledInput.fieldView.placeholder = 'foo';
+			expect( labeledInput.placeholder ).to.equal( 'foo' );
+		} );
+
 		it( 'should clean labeledInput#errorText upon input\'s DOM "update" event', () => {
 			labeledInput.errorText = 'some error';
 			labeledInput.fieldView.fire( 'input' );