浏览代码

Tests: Added tests for LabelView#id.

Aleksander Nowodzinski 5 年之前
父节点
当前提交
bb66221d60
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 2 1
      packages/ckeditor5-ui/src/label/labelview.js
  2. 9 0
      packages/ckeditor5-ui/tests/label/labelview.js

+ 2 - 1
packages/ckeditor5-ui/src/label/labelview.js

@@ -41,7 +41,8 @@ export default class LabelView extends View {
 		this.set( 'for' );
 
 		/**
-		 * TODO
+		 * An unique id of the label. It can be used by other UI components to reference
+		 * the label, for instance, using the `aria-describedby` DOM attribute.
 		 *
 		 * @member {String} #id
 		 */

+ 9 - 0
packages/ckeditor5-ui/tests/label/labelview.js

@@ -20,6 +20,15 @@ describe( 'LabelView', () => {
 			expect( view.element.classList.contains( 'ck' ) ).to.be.true;
 			expect( view.element.classList.contains( 'ck-label' ) ).to.be.true;
 		} );
+
+		it( 'should define the #id', () => {
+			expect( view.id ).to.match( /^ck-editor__label_.+/ );
+		} );
+
+		it( 'should assign an #id to the #element attribute', () => {
+			expect( view.element.id ).to.equal( view.id );
+			expect( view.element.id ).to.match( /^ck-editor__label_.+/ );
+		} );
 	} );
 
 	describe( 'DOM bindings', () => {