How to use the @ckeditor/ckeditor5-utils/tests/_utils/utils.expectToThrowCKEditorError function in @ckeditor/ckeditor5-utils

To help you get started, we’ve selected a few @ckeditor/ckeditor5-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-engine / tests / model / operation / attributeoperation.js View on Github external
it( 'should throw for a non-flat range', () => {
			root._insertChild( 0, [
				new Element( 'paragraph', null, new Text( 'Foo' ) ),
				new Element( 'paragraph', null, new Text( 'Bar' ) )
			] );

			expectToThrowCKEditorError( () => {
				const operation = new AttributeOperation(
					new Range( new Position( root, [ 0, 1 ] ), new Position( root, [ 1, 1 ] ) ),
					'x',
					null,
					2,
					doc.version
				);

				operation._validate();
			}, /attribute-operation-range-not-flat/, model );
		} );
	} );
github ckeditor / ckeditor5-engine / tests / model / writer.js View on Github external
it( 'should throw if element to unwrap has no parent', () => {
			const element = new Element( 'p' );

			expectToThrowCKEditorError( () => {
				unwrap( element );
			}, /^writer-unwrap-element-no-parent/, model );
		} );
github ckeditor / ckeditor5-engine / tests / model / writer.js View on Github external
it( 'should throw when moving element from document to document fragment', () => {
			const root = doc.createRoot();
			const docFrag = createDocumentFragment();
			const node = createText( 'foo' );

			insert( node, root );

			expectToThrowCKEditorError( () => {
				insert( node, docFrag );
			}, /^model-writer-insert-forbidden-move/, model );
		} );
github ckeditor / ckeditor5-engine / tests / model / nodelist.js View on Github external
it( 'should throw if given offset is too high or too low', () => {
			expectToThrowCKEditorError( () => {
				nodes.offsetToIndex( -1 );
			}, /nodelist-offset-out-of-bounds/, nodes );

			expectToThrowCKEditorError( () => {
				nodes.offsetToIndex( 55 );
			}, /nodelist-offset-out-of-bounds/, nodes );
		} );
github ckeditor / ckeditor5-engine / tests / model / operation / splitoperation.js View on Github external
it( 'should throw an error if split position is invalid', () => {
			const p1 = new Element( 'p1', null, new Text( 'Foobar' ) );

			root._insertChild( 0, [ p1 ] );

			const operation = new SplitOperation( new Position( root, [ 0, 8 ] ), 3, null, doc.version );

			expectToThrowCKEditorError( () => operation._validate(), /split-operation-position-invalid/, model );
		} );
github ckeditor / ckeditor5-core / tests / editor / utils / attachtoform.js View on Github external
it( 'should throw an error when is used with editor without `ElementApiMixin`', () => {
		const editor = new Editor();

		expectToThrowCKEditorError( () => {
			attachToForm( editor );
		}, /^attachtoform-missing-elementapi-interface/, editor );
	} );
github ckeditor / ckeditor5-engine / tests / view / documentselection.js View on Github external
it( 'should throw an error when trying to set to not selectable', () => {
				const otherSelection = new DocumentSelection();

				expectToThrowCKEditorError( () => {
					otherSelection._setTo( {} );
				}, /view-selection-setTo-not-selectable/ );
			} );
github ckeditor / ckeditor5-engine / tests / model / writer.js View on Github external
it( 'should throw if not an Element instance is passed', () => {
			expectToThrowCKEditorError( () => {
				rename( new Text( 'abc' ), 'h' );
			}, /^writer-rename-not-element-instance/, model );
		} );
github ckeditor / ckeditor5-engine / tests / view / documentselection.js View on Github external
it( 'should throw an error when the second parameter is not passed and first is an item', () => {
				const foo = new Text( 'foo' );

				expectToThrowCKEditorError( () => {
					documentSelection._setTo( foo );
				}, /view-selection-setTo-required-second-parameter/, documentSelection );
			} );
github ckeditor / ckeditor5-engine / tests / model / operation / splitoperation.js View on Github external
it( 'should throw an error if split position is in root', () => {
			const p1 = new Element( 'p1', null, new Text( 'Foobar' ) );

			root._insertChild( 0, [ p1 ] );

			const operation = new SplitOperation( new Position( root, [ 0, 0 ] ), 3, null, doc.version );
			operation.splitPosition = new Position( root, [ 1 ] );

			expectToThrowCKEditorError( () => operation._validate(), /split-operation-split-in-root/, model );
		} );