Skip to content

Commit

Permalink
Added EmptyBlock integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Jan 22, 2025
1 parent e0d570d commit b6ed3d5
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions packages/ckeditor5-list/tests/list/integrations/emptyblock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/

import ListEditing from '../../../src/list/listediting.js';

import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting.js';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
import EmptyBlock from '@ckeditor/ckeditor5-html-support/src/emptyblock.js';
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';

import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor.js';
import { setupTestHelpers } from '../_utils/utils.js';
import stubUid from '../_utils/uid.js';

describe( 'ListEditing - EmptyBlock integration', () => {
let editor, view, test;

testUtils.createSinonSandbox();

beforeEach( async () => {
editor = await VirtualTestEditor.create( {
plugins: [ Paragraph, ListEditing, HeadingEditing, EmptyBlock ]
} );

view = editor.editing.view;

// Stub `view.scrollToTheSelection` as it will fail on VirtualTestEditor without DOM.
sinon.stub( view, 'scrollToTheSelection' ).callsFake( () => {} );
stubUid();

test = setupTestHelpers( editor );
} );

afterEach( async () => {
await editor.destroy();
} );

it( 'inside a plain li element', () => {
test.data(
'<ul>' +
'<li>x</li>' +
'<li>&nbsp;</li>' +
'<li></li>' +
'</ul>',

'<paragraph listIndent="0" listItemId="a00" listType="bulleted">x</paragraph>' +
'<paragraph listIndent="0" listItemId="a01" listType="bulleted"></paragraph>' +
'<paragraph htmlEmptyBlock="true" listIndent="0" listItemId="a02" listType="bulleted"></paragraph>'
);
} );

it( 'inside a paragraph in a li element', () => {
test.data(
'<ul>' +
'<li><p>x</p></li>' +
'<li><p>&nbsp;</p></li>' +
'<li><p></p></li>' +
'</ul>',

'<paragraph listIndent="0" listItemId="a00" listType="bulleted">x</paragraph>' +
'<paragraph listIndent="0" listItemId="a01" listType="bulleted"></paragraph>' +
'<paragraph htmlEmptyBlock="true" listIndent="0" listItemId="a02" listType="bulleted"></paragraph>',

'<ul>' +
'<li>x</li>' +
'<li>&nbsp;</li>' +
'<li></li>' +
'</ul>'
);
} );

it( 'inside a heading in a li element', () => {
test.data(
'<ul>' +
'<li><h2>x</h2></li>' +
'<li><h2>&nbsp;</h2></li>' +
'<li><h2></h2></li>' +
'</ul>',

'<heading1 listIndent="0" listItemId="a00" listType="bulleted">x</heading1>' +
'<heading1 listIndent="0" listItemId="a01" listType="bulleted"></heading1>' +
'<heading1 htmlEmptyBlock="true" listIndent="0" listItemId="a02" listType="bulleted"></heading1>',

'<ul>' +
'<li><h2>x</h2></li>' +
'<li><h2>&nbsp;</h2></li>' +
'<li><h2></h2></li>' +
'</ul>'
);
} );
} );

0 comments on commit b6ed3d5

Please sign in to comment.