mirror of
https://github.com/codex-team/editor.js
synced 2024-06-03 06:22:39 +02:00
2ab9eb13bc
* feat(block-events): delete keydown logic added * chore(ui-events): delete keydown will remove selected blocks * backspace tests added * delete keydown tests * tests for ui added * fix ci * separate block events tests for several files * Delete BlockEvents.cy.ts * rm unused change * add code-review fixes + corner cases handling * Update blockEvents.ts * allow merging only same type blocks
97 lines
2.4 KiB
TypeScript
97 lines
2.4 KiB
TypeScript
import type EditorJS from '../../../../types/index';
|
|
|
|
describe('Ui module', function () {
|
|
describe('documentKeydown', function () {
|
|
describe('Backspace', function () {
|
|
it('should remove selected blocks', function () {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
id: 'block1',
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The first block',
|
|
},
|
|
},
|
|
{
|
|
id: 'block2',
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The second block',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}).as('editorInstance');
|
|
|
|
/**
|
|
* Select two blocks by shift+down
|
|
*/
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.first()
|
|
.click()
|
|
.type('{shift+downArrow}')
|
|
.type('{backspace}');
|
|
|
|
|
|
cy.get<EditorJS>('@editorInstance')
|
|
.then(async (editor) => {
|
|
const { blocks } = await editor.save();
|
|
|
|
/**
|
|
* Actually editor will contain 1 empty block, but save wont return it since it is empty
|
|
*/
|
|
expect(blocks.length).to.eq(0);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('Delete', function () {
|
|
it('should remove selected blocks', function () {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [
|
|
{
|
|
id: 'block1',
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The first block',
|
|
},
|
|
},
|
|
{
|
|
id: 'block2',
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The second block',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
}).as('editorInstance');
|
|
|
|
/**
|
|
* Select two blocks by shift+down
|
|
*/
|
|
cy.get('[data-cy=editorjs]')
|
|
.find('.ce-paragraph')
|
|
.first()
|
|
.click()
|
|
.type('{shift+downArrow}')
|
|
.type('{del}');
|
|
|
|
cy.get<EditorJS>('@editorInstance')
|
|
.then(async (editor) => {
|
|
const { blocks } = await editor.save();
|
|
|
|
/**
|
|
* Actually editor will contain 1 empty block, but save wont return it since it is empty
|
|
*/
|
|
expect(blocks.length).to.eq(0);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|