/**
* @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 { testDataProcessor } from '../_utils/utils';
describe( 'GFMDataProcessor', () => {
describe( 'lists', () => {
it( 'should process tight asterisks', () => {
testDataProcessor(
'* item 1\n' +
'* item 2\n' +
'* item 3',
// GitHub renders it as (notice spaces before list items)
//
// - item 1
// - item 2
// - item 3
//
'',
// List will be normalized to 3-space representation.
'* item 1\n' +
'* item 2\n' +
'* item 3'
);
} );
it( 'should process loose asterisks', () => {
testDataProcessor(
'* item 1\n' +
'\n' +
'* item 2\n' +
'\n' +
'* item 3',
// Loose lists are rendered with with paragraph inside.
'' +
'- ' +
'
item 1
' +
' ' +
'- ' +
'
item 2
' +
' ' +
'- ' +
'
item 3
' +
' ' +
'
',
// List will be normalized to 3-space representation.
'* item 1\n' +
'\n' +
'* item 2\n' +
'\n' +
'* item 3'
);
} );
it( 'should process tight pluses', () => {
testDataProcessor(
'+ item 1\n' +
'+ item 2\n' +
'+ item 3',
'' +
'- item 1
' +
'- item 2
' +
'- item 3
' +
'
',
// List will be normalized to asterisks, 3-space representation.
'* item 1\n' +
'* item 2\n' +
'* item 3'
);
} );
it( 'should process loose pluses', () => {
testDataProcessor(
'+ item 1\n' +
'\n' +
'+ item 2\n' +
'\n' +
'+ item 3',
'' +
'- ' +
'
item 1
' +
' ' +
'- ' +
'
item 2
' +
' ' +
'- ' +
'
item 3
' +
' ' +
'
',
// List will be normalized to asterisks, 3-space representation.
'* item 1\n' +
'\n' +
'* item 2\n' +
'\n' +
'* item 3'
);
} );
it( 'should process tight minuses', () => {
testDataProcessor(
'- item 1\n' +
'- item 2\n' +
'- item 3',
'' +
'- item 1
' +
'- item 2
' +
'- item 3
' +
'
',
// List will be normalized to asterisks, 3-space representation.
'* item 1\n' +
'* item 2\n' +
'* item 3'
);
} );
it( 'should process loose minuses', () => {
testDataProcessor(
'- item 1\n' +
'\n' +
'- item 2\n' +
'\n' +
'- item 3',
'' +
'- ' +
'
item 1
' +
' ' +
'- ' +
'
item 2
' +
' ' +
'- ' +
'
item 3
' +
' ' +
'
',
// List will be normalized to asterisks, 3-space representation.
'* item 1\n' +
'\n' +
'* item 2\n' +
'\n' +
'* item 3'
);
} );
it( 'should process ordered list with tabs', () => {
testDataProcessor(
'1. item 1\n' +
'2. item 2\n' +
'3. item 3',
'' +
'- item 1
' +
'- item 2
' +
'- item 3
' +
'
',
// List will be normalized to 2-space representation.
'1. item 1\n' +
'2. item 2\n' +
'3. item 3'
);
} );
it( 'should process ordered list with spaces', () => {
testDataProcessor(
'1. item 1\n' +
'2. item 2\n' +
'3. item 3',
'' +
'- item 1
' +
'- item 2
' +
'- item 3
' +
'
',
// List will be normalized to 2-space representation.
'1. item 1\n' +
'2. item 2\n' +
'3. item 3'
);
} );
it( 'should process loose ordered list with tabs', () => {
testDataProcessor(
'1. item 1\n' +
'\n' +
'2. item 2\n' +
'\n' +
'3. item 3',
'' +
'- ' +
'
item 1
' +
' ' +
'- ' +
'
item 2
' +
' ' +
'- ' +
'
item 3
' +
' ' +
'
',
// List will be normalized to 2-space representation.
'1. item 1\n' +
'\n' +
'2. item 2\n' +
'\n' +
'3. item 3'
);
} );
it( 'should process loose ordered list with spaces', () => {
testDataProcessor(
'1. item 1\n' +
'\n' +
'2. item 2\n' +
'\n' +
'3. item 3',
'' +
'- ' +
'
item 1
' +
' ' +
'- ' +
'
item 2
' +
' ' +
'- ' +
'
item 3
' +
' ' +
'
',
// List will be normalized to 2-space representation.
'1. item 1\n' +
'\n' +
'2. item 2\n' +
'\n' +
'3. item 3'
);
} );
it( 'should process nested and mixed lists', () => {
testDataProcessor(
'1. First\n' +
'2. Second:\n' +
' * Fee\n' +
' * Fie\n' +
' * Foe\n' +
'3. Third',
'' +
'- First
' +
'- Second:' +
'
' +
'- Fee
' +
'- Fie
' +
'- Foe
' +
'
' +
' ' +
'- Third
' +
'
',
// All lists will be normalized after converting back.
'1. First\n' +
'2. Second:\n' +
' * Fee\n' +
' * Fie\n' +
' * Foe\n' +
'3. Third'
);
} );
it( 'should process nested and mixed loose lists', () => {
testDataProcessor(
'1. First\n' +
'\n' +
'2. Second:\n' +
' * Fee\n' +
' * Fie\n' +
' * Foe\n' +
'\n' +
'3. Third',
'' +
'- ' +
'
First
' +
' ' +
'- ' +
'
Second:
' +
'' +
'- Fee
' +
'- Fie
' +
'- Foe
' +
'
' +
' ' +
'- ' +
'
Third
' +
' ' +
'
',
// All lists will be normalized after converting back.
'1. First\n' +
'\n' +
'2. Second:\n' +
'\n' +
' * Fee\n' +
' * Fie\n' +
' * Foe\n' +
'3. Third'
);
} );
it( 'should create same bullet from different list indicators', () => {
testDataProcessor(
'* test\n' +
'+ test\n' +
'- test',
'' +
'- test
' +
'- test
' +
'- test
' +
'
',
// After converting back list items will be unified.
'* test\n' +
'* test\n' +
'* test'
);
} );
} );
} );