Преглед изворни кода

Add test for selection with mixed parts of text.

Maciej Gołaszewski пре 6 година
родитељ
комит
78759c9f70

+ 12 - 1
packages/ckeditor5-restricted-editing/tests/restricteddocumentcommand.js

@@ -108,7 +108,7 @@ describe( 'RestrictedDocumentCommand', () => {
 		} );
 	} );
 
-	describe( 'execute()', () => {
+	describe.only( 'execute()', () => {
 		it( 'should do nothing if the command is disabled', () => {
 			setData( model, '<p>fo[ob]ar</p>' );
 
@@ -130,6 +130,17 @@ describe( 'RestrictedDocumentCommand', () => {
 			expect( getData( model ) ).to.equal( '<p>foo[<$text nonRestricted="true">bar</$text>]baz</p>' );
 		} );
 
+		it( 'should add attribute on selected nodes if the command value was false (non-restricted text in selection)', () => {
+			setData( model, '<p>[foo<$text nonRestricted="true">bar</$text>]baz</p>' );
+
+			expect( command.value ).to.be.false;
+
+			command.execute();
+
+			expect( command.value ).to.be.true;
+			expect( getData( model ) ).to.equal( '<p>[<$text nonRestricted="true">foobar</$text>]baz</p>' );
+		} );
+
 		it( 'should remove attribute from selected nodes if the command value was true', () => {
 			setData( model, '<p>abc[<$text nonRestricted="true">foo]bar</$text>xyz</p>' );