| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- /**
- * @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, parse } from '/tests/engine/_utils/view.js';
- describe( 'GFMDataProcessor', () => {
- let dataProcessor;
- beforeEach( () => {
- dataProcessor = new MarkdownDataProcessor();
- } );
- describe( 'horizontal rules', () => {
- describe( 'toView', () => {
- describe( 'dashes', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '---' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' ---' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' ---' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' ---' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' ---' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>---</code></pre>' );
- } );
- } );
- describe( 'dashes with spaces', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '- - -' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' - - -' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' - - -' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' - - -' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' - - -' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>- - -</code></pre>' );
- } );
- } );
- describe( 'asterisks', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '***' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' ***' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' ***' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' ***' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' ***' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>***</code></pre>' );
- } );
- } );
- describe( 'asterisks with spaces', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '* * *' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' * * *' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' * * *' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' * * *' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' * * *' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>* * *</code></pre>' );
- } );
- } );
- describe( 'underscores', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '___' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' ___' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' ___' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' ___' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' ___' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>___</code></pre>' );
- } );
- } );
- describe( 'underscores with spaces', () => {
- it( '#1', () => {
- const viewFragment = dataProcessor.toView( '_ _ _' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#2', () => {
- const viewFragment = dataProcessor.toView( ' _ _ _' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#3', () => {
- const viewFragment = dataProcessor.toView( ' _ _ _' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#4', () => {
- const viewFragment = dataProcessor.toView( ' _ _ _' );
- expect( stringify( viewFragment ) ).to.equal( '<hr></hr>' );
- } );
- it( '#5 - code', () => {
- const viewFragment = dataProcessor.toView( ' _ _ _' );
- expect( stringify( viewFragment ) ).to.equal( '<pre><code>_ _ _</code></pre>' );
- } );
- } );
- } );
- describe( 'toData', () => {
- it( 'should process horizontal rules', () => {
- const viewFragment = parse( '<hr></hr>' );
- expect( dataProcessor.toData( viewFragment ) ).to.equal( '* * *' );
- } );
- } );
- } );
- } );
|