瀏覽代碼

Add unit test for toolbar.

Mateusz Samsel 6 年之前
父節點
當前提交
c03b6dcb90
共有 1 個文件被更改,包括 32 次插入0 次删除
  1. 32 0
      packages/ckeditor5-ui/tests/toolbar/toolbarview.js

+ 32 - 0
packages/ckeditor5-ui/tests/toolbar/toolbarview.js

@@ -56,6 +56,10 @@ describe( 'ToolbarView', () => {
 		it( 'creates #_focusCycler instance', () => {
 			expect( view._focusCycler ).to.be.instanceOf( FocusCycler );
 		} );
+
+		it( 'sets #labelView', () => {
+			expect( view.labelView ).to.be.instanceOf( View );
+		} );
 	} );
 
 	describe( 'template', () => {
@@ -321,6 +325,34 @@ describe( 'ToolbarView', () => {
 			);
 		} );
 	} );
+
+	describe( 'aria', () => {
+		it( 'poses required attributes', () => {
+			expect( view.element.getAttribute( 'role' ) ).to.equal( 'toolbar' );
+			expect( view.element.getAttribute( 'aria-labelledby' ) ).to.equal( view.labelView.element.id )
+				.and.to.match( /^ck-editor__aria-label_[0-9a-f]{16}/ );
+		} );
+	} );
+
+	describe( '_createLabelView()', () => {
+		let labelElement;
+
+		beforeEach( () => {
+			labelElement = view.labelView.element;
+		} );
+
+		it( 'label is attached as last element in toolbar', () => {
+			expect( labelElement ).to.equal( view.element.lastElementChild );
+		} );
+
+		it( 'label has proper attributes', () => {
+			view.label = 'Foo';
+
+			expect( labelElement.innerHTML ).to.equal( 'Foo' );
+			expect( labelElement.classList.contains( 'ck' ) ).to.be.true;
+			expect( labelElement.classList.contains( 'ck-toolbar__label' ) ).to.be.true;
+		} );
+	} );
 } );
 
 function focusable() {