|
|
@@ -3,18 +3,7 @@
|
|
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
|
*/
|
|
|
|
|
|
-/* globals document */
|
|
|
-
|
|
|
-import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
|
|
|
-
|
|
|
-import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
|
|
-import Image from '../../src/image';
|
|
|
-import ImageUploadUI from '../../src/imageupload/imageuploadui';
|
|
|
-import ImageUploadEditing from '../../src/imageupload/imageuploadediting';
|
|
|
-import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
|
|
|
-import Link from '@ckeditor/ckeditor5-link/src/link';
|
|
|
-import CKFinder from '@ckeditor/ckeditor5-ckfinder/src/ckfinder';
|
|
|
-import { createImageTypeRegExp, prepareIntegrations, createLabeledInputView } from '../../src/imageupload/utils';
|
|
|
+import { createImageTypeRegExp } from '../../src/imageupload/utils';
|
|
|
|
|
|
describe( 'Upload utils', () => {
|
|
|
describe( 'createImageTypeRegExp()', () => {
|
|
|
@@ -42,138 +31,4 @@ describe( 'Upload utils', () => {
|
|
|
expect( createImageTypeRegExp( [ 'png' ] ).test( 'svg+xml' ) ).to.be.false;
|
|
|
} );
|
|
|
} );
|
|
|
-
|
|
|
- describe( 'prepareIntegrations()', () => {
|
|
|
- it( 'should return "insetImageViaUrl" and "openCKFinder" integrations', async () => {
|
|
|
- const editorElement = document.createElement( 'div' );
|
|
|
- document.body.appendChild( editorElement );
|
|
|
-
|
|
|
- const editor = await ClassicEditor
|
|
|
- .create( editorElement, {
|
|
|
- plugins: [
|
|
|
- CKFinder,
|
|
|
- Paragraph,
|
|
|
- Image,
|
|
|
- ImageUploadEditing,
|
|
|
- ImageUploadUI
|
|
|
- ],
|
|
|
- image: {
|
|
|
- upload: {
|
|
|
- panel: {
|
|
|
- items: [
|
|
|
- 'insertImageViaUrl',
|
|
|
- 'openCKFinder'
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } );
|
|
|
-
|
|
|
- const openCKFinderExtendedView = Object.values( prepareIntegrations( editor ) )[ 1 ];
|
|
|
-
|
|
|
- expect( openCKFinderExtendedView.class ).contains( 'ck-image-upload__ck-finder-button' );
|
|
|
- expect( openCKFinderExtendedView.label ).to.equal( 'Insert image or file' );
|
|
|
- expect( openCKFinderExtendedView.withText ).to.be.true;
|
|
|
-
|
|
|
- editor.destroy();
|
|
|
- editorElement.remove();
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return only "insertImageViaUrl" integration and throw warning' +
|
|
|
- 'for "image-upload-integrations-invalid-view" error', async () => {
|
|
|
- const editorElement = document.createElement( 'div' );
|
|
|
- document.body.appendChild( editorElement );
|
|
|
-
|
|
|
- const editor = await ClassicEditor
|
|
|
- .create( editorElement, {
|
|
|
- plugins: [
|
|
|
- Paragraph,
|
|
|
- Image,
|
|
|
- ImageUploadEditing,
|
|
|
- ImageUploadUI
|
|
|
- ],
|
|
|
- image: {
|
|
|
- upload: {
|
|
|
- panel: {
|
|
|
- items: [
|
|
|
- 'insertImageViaUrl',
|
|
|
- 'openCKFinder'
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } );
|
|
|
-
|
|
|
- expect( Object.values( prepareIntegrations( editor ) ).length ).to.equal( 1 );
|
|
|
-
|
|
|
- editor.destroy();
|
|
|
- editorElement.remove();
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return only "link" integration', async () => {
|
|
|
- const editorElement = document.createElement( 'div' );
|
|
|
- document.body.appendChild( editorElement );
|
|
|
-
|
|
|
- const editor = await ClassicEditor
|
|
|
- .create( editorElement, {
|
|
|
- plugins: [
|
|
|
- Paragraph,
|
|
|
- Link,
|
|
|
- Image,
|
|
|
- ImageUploadEditing,
|
|
|
- ImageUploadUI
|
|
|
- ],
|
|
|
- image: {
|
|
|
- upload: {
|
|
|
- panel: {
|
|
|
- items: [
|
|
|
- 'link'
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } );
|
|
|
-
|
|
|
- expect( Object.values( prepareIntegrations( editor ) ).length ).to.equal( 1 );
|
|
|
- expect( Object.values( prepareIntegrations( editor ) )[ 0 ].label ).to.equal( 'Link' );
|
|
|
- expect( Object.values( prepareIntegrations( editor ) )[ 0 ] ).to.be.instanceOf( ButtonView );
|
|
|
-
|
|
|
- editor.destroy();
|
|
|
- editorElement.remove();
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should return "insertImageViaUrl" integration, when no integrations were configured', async () => {
|
|
|
- const editorElement = document.createElement( 'div' );
|
|
|
- document.body.appendChild( editorElement );
|
|
|
-
|
|
|
- const editor = await ClassicEditor
|
|
|
- .create( editorElement, {
|
|
|
- plugins: [
|
|
|
- Paragraph,
|
|
|
- Image,
|
|
|
- ImageUploadEditing,
|
|
|
- ImageUploadUI
|
|
|
- ]
|
|
|
- } );
|
|
|
-
|
|
|
- expect( Object.keys( prepareIntegrations( editor ) ).length ).to.equal( 1 );
|
|
|
-
|
|
|
- editor.destroy();
|
|
|
- editorElement.remove();
|
|
|
- } );
|
|
|
- } );
|
|
|
-
|
|
|
- describe( 'createLabeledInputView()', () => {
|
|
|
- describe( 'image URL input view', () => {
|
|
|
- it( 'should have placeholder', () => {
|
|
|
- const view = createLabeledInputView( { t: val => val } );
|
|
|
- expect( view.fieldView.placeholder ).to.equal( 'https://example.com/src/image.png' );
|
|
|
- } );
|
|
|
-
|
|
|
- it( 'should have info text', () => {
|
|
|
- const view = createLabeledInputView( { t: val => val } );
|
|
|
- expect( view.infoText ).to.match( /^Paste the image source URL/ );
|
|
|
- } );
|
|
|
- } );
|
|
|
- } );
|
|
|
} );
|