/** * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md. */ import MarkdownDataProcessor from '/ckeditor5/markdown-gfm/gfmdataprocessor.js'; import { stringify } from '/tests/engine/_utils/view.js'; describe( 'GFMDataProcessor', () => { let dataProcessor; beforeEach( () => { dataProcessor = new MarkdownDataProcessor(); } ); describe( 'tables', () => { describe( 'toView', () => { it( 'should process tables', () => { const viewFragment = dataProcessor.toView( '| Heading 1 | Heading 2\n' + '| --------- | ---------\n' + '| Cell 1 | Cell 2\n' + '| Cell 3 | Cell 4\n' ); expect( stringify( viewFragment ) ).to.equal( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
Heading 1Heading 2
Cell 1Cell 2
Cell 3Cell 4
' ); } ); it( 'should process tables with aligned columns', () => { const viewFragment = dataProcessor.toView( '| Header 1 | Header 2 | Header 3 | Header 4 |\n' + '| :------: | -------: | :------- | -------- |\n' + '| Cell 1 | Cell 2 | Cell 3 | Cell 4 |\n' + '| Cell 5 | Cell 6 | Cell 7 | Cell 8 |' ); expect( stringify( viewFragment ) ).to.equal( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
Cell 5Cell 6Cell 7Cell 8
' ); } ); it( 'should process not table without borders', () => { const viewFragment = dataProcessor.toView( 'Header 1 | Header 2\n' + '-------- | --------\n' + 'Cell 1 | Cell 2\n' + 'Cell 3 | Cell 4' ); expect( stringify( viewFragment ) ).to.equal( '' + '' + '' + '' + '' + '' + '' + '' + '
Header 1Header 2
Cell 1Cell 2
Cell 3Cell 4
' ); } ); it( 'should process formatting inside cells', () => { const viewFragment = dataProcessor.toView( 'Header 1|Header 2|Header 3|Header 4\n' + ':-------|:------:|-------:|--------\n' + '*Cell 1* |**Cell 2** |~~Cell 3~~ |Cell 4' ); expect( stringify( viewFragment ) ).to.equal( '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
Header 1Header 2Header 3Header 4
Cell 1Cell 2Cell 3Cell 4
' ); } ); } ); } ); } );