8
0
Просмотр исходного кода

Added a test for todo lists when loading the HTML produced by the todo list feature.

fredck 5 лет назад
Родитель
Сommit
c30bd15ad4
1 измененных файлов с 25 добавлено и 0 удалено
  1. 25 0
      packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/lists.js

+ 25 - 0
packages/ckeditor5-markdown-gfm/tests/gfmdataprocessor/lists.js

@@ -4,6 +4,8 @@
  */
 
 import { testDataProcessor } from '../_utils/utils';
+import MarkdownDataProcessor from '../../src/gfmdataprocessor';
+import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
 
 describe( 'GFMDataProcessor', () => {
 	describe( 'lists', () => {
@@ -352,5 +354,28 @@ describe( 'GFMDataProcessor', () => {
 					'<li><input checked="" disabled="" type="checkbox"></input>Item 2</li>' +
 				'</ul>' );
 		} );
+
+		it( 'should process the HTML produced by the todo list feature', () => {
+			const htmlDataProcessor = new HtmlDataProcessor();
+			const mdDataProcessor = new MarkdownDataProcessor();
+
+			const viewFragment = htmlDataProcessor.toView(
+				'<ul class="todo-list">' +
+					'<li><label class="todo-list__label">' +
+						'<input type="checkbox" disabled="disabled">' +
+						'<span class="todo-list__label__description">Item 1</span>' +
+					'</label></li>' +
+					'<li><label class="todo-list__label">' +
+						'<input type="checkbox" disabled="disabled" checked="checked">' +
+						'<span class="todo-list__label__description">Item 2</span>' +
+					'</label></li>' +
+				'</ul>'
+			);
+
+			expect( mdDataProcessor.toData( viewFragment ) ).to.equal(
+				'*   [ ] List 1\n' +
+				'*   [x] Item 2'
+			);
+		} );
 	} );
 } );