it('should remove previous Block if Caret at the start of the Block and previous Block is empty. Also, should close the Toolbox',function(){
cy.createEditor({
data:{
blocks:[
{
id:'block1',
type:'paragraph',
data:{
text:'',// empty block
},
},
{
id:'block2',
type:'paragraph',
data:{
text:'Not empty block',
},
},
],
},
}).as('editorInstance');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.click()
.type('{home}')// move caret to the beginning
.type('{backspace}');
cy.get<EditorJS>('@editorInstance')
.then(async(editor)=>{
const{blocks}=awaiteditor.save();
expect(blocks.length).to.eq(1);// one block has been removed
expect(blocks[0].id).to.eq('block2');// second block is still here
});
});
it('should remove current Block if it is empty, but previous is not. Also, should close the Toolbox and set Caret to the end of the prev Block',function(){
cy.createEditor({
data:{
blocks:[
{
id:'block1',
type:'paragraph',
data:{
text:'Not empty block',
},
},
{
id:'block2',
type:'paragraph',
data:{
text:'',// empty block
},
},
],
},
}).as('editorInstance');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.click()
.type('{backspace}');
/**
*CurrentBlockhasbeenremoved
*/
cy.get<EditorJS>('@editorInstance')
.then(async(editor)=>{
const{blocks}=awaiteditor.save();
expect(blocks.length).to.eq(1);// one block has been removed
expect(blocks[0].id).to.eq('block1');// second block is still here
it('should merge current Block with the previous one if Caret at the start of the Block and both Blocks are mergeable. Also, should close the Toolbox. Caret should be places in a place of glue',function(){
cy.createEditor({
data:{
blocks:[
{
id:'block1',
type:'paragraph',
data:{
text:'First block',
},
},
{
id:'block2',
type:'paragraph',
data:{
text:'Second block',
},
},
],
},
}).as('editorInstance');
cy.get('[data-cy=editorjs]')
.find('.ce-paragraph')
.last()
.click()
.type('{home}')// move caret to the beginning
.type('{backspace}');
/**
*CurrentBlockhasbeenremoved
*/
cy.get<EditorJS>('@editorInstance')
.then(async(editor)=>{
const{blocks}=awaiteditor.save();
expect(blocks.length).to.eq(1);// one block has been removed
expect(blocks[0].id).to.eq('block1');// second block is still here
expect(blocks[0].data.text).to.eq('First blockSecond block');// text has been merged
it('should simply set Caret to the end of the previous Block if Caret at the start of the Block but Blocks are not mergeable. Also, should close the Toolbox.',function(){