Skip to content

Commit

Permalink
Merge pull request #7297 from ckeditor/i/5977
Browse files Browse the repository at this point in the history
Tests (code-block): Added tests to ensure that the code-block plugin works with markdown. See #5977.
  • Loading branch information
jodator authored Aug 17, 2020
2 parents 1738d0f + d9173a1 commit e876bc7
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ckeditor5-code-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@ckeditor/ckeditor5-editor-classic": "^21.0.0",
"@ckeditor/ckeditor5-engine": "^21.0.0",
"@ckeditor/ckeditor5-indent": "^21.0.0",
"@ckeditor/ckeditor5-markdown-gfm": "^21.0.0",
"@ckeditor/ckeditor5-paragraph": "^21.0.0",
"@ckeditor/ckeditor5-undo": "^21.0.0"
},
Expand Down
62 changes: 62 additions & 0 deletions packages/ckeditor5-code-block/tests/codeblock-integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

import CodeBlockEditing from '../src/codeblockediting';

// A simple plugin that enables the GFM data processor.
class CodeBlockIntegration extends Plugin {
constructor( editor ) {
super( editor );
editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
}
}

function getEditor( initialData = '' ) {
return ClassicTestEditor
.create( initialData, {
plugins: [ CodeBlockIntegration, CodeBlockEditing, Enter, Paragraph ]
} );
}

describe( 'CodeBlock - integration', () => {
describe( 'with Markdown GFM', () => {
it( 'should be loaded and returned from the editor (for plain text)', async () => {
const editor = await getEditor(
'```\n' +
'test()\n' +
'```'
);

expect( editor.getData() ).to.equal(
'```plaintext\n' +
'test()\n' +
'```'
);

await editor.destroy();
} );
it( 'should be loaded and returned from the editor (for defined language)', async () => {
const editor = await getEditor(
'```javascript\n' +
'test()\n' +
'```'
);

expect( editor.getData() ).to.equal(
'```javascript\n' +
'test()\n' +
'```'
);

await editor.destroy();
} );
} );
} );

0 comments on commit e876bc7

Please sign in to comment.