8
0
Quellcode durchsuchen

Add one more test which checks attributes that are set manually.

Kamil Piechaczek vor 7 Jahren
Ursprung
Commit
3938f6df4e
1 geänderte Dateien mit 16 neuen und 3 gelöschten Zeilen
  1. 16 3
      packages/ckeditor5-engine/tests/model/schema.js

+ 16 - 3
packages/ckeditor5-engine/tests/model/schema.js

@@ -1053,6 +1053,7 @@ describe( 'Schema', () => {
 				if ( inTextWithBold( ctx ) && attributeName == 'italic' ) {
 					return false;
 				}
+
 				// Allow 'italic' on p>$text.
 				if ( ctx.endsWith( 'p $text' ) && attributeName == 'italic' ) {
 					return true;
@@ -1083,20 +1084,32 @@ describe( 'Schema', () => {
 				expect( schema.checkAttributeInSelection( doc.selection, attribute ) ).to.be.false;
 			} );
 
-			it( 'should check attributes of text (selection at the beginning of the text)', () => {
+			it( 'should check attributes of the selection (selection at the beginning of the text)', () => {
 				setData( model, '<p><$text bold="true">[]foo</$text></p>' );
 				expect( schema.checkAttributeInSelection( doc.selection, 'italic' ) ).to.be.false;
 			} );
 
-			it( 'should check attributes of text (selection inside the text)', () => {
+			it( 'should check attributes of the selection (selection inside the text)', () => {
 				setData( model, '<p><$text bold="true">f[]oo</$text></p>' );
 				expect( schema.checkAttributeInSelection( doc.selection, 'italic' ) ).to.be.false;
 			} );
 
-			it( 'should check attributes of text (selection at the end of the text)', () => {
+			it( 'should check attributes of the selection (selection at the end of the text)', () => {
 				setData( model, '<p><$text bold="true">foo[]</$text></p>' );
 				expect( schema.checkAttributeInSelection( doc.selection, 'italic' ) ).to.be.false;
 			} );
+
+			it( 'should check attributes of the selection (an attribute sets manually)', () => {
+				setData( model, '<p>foo[]bar</p>' );
+
+				expect( schema.checkAttributeInSelection( doc.selection, 'italic' ) ).to.be.true;
+
+				model.change( writer => {
+					writer.setSelectionAttribute( 'bold', true );
+				} );
+
+				expect( schema.checkAttributeInSelection( doc.selection, 'italic' ) ).to.be.false;
+			} );
 		} );
 
 		describe( 'when selection is not collapsed', () => {