mirror of
https://github.com/codex-team/editor.js
synced 2024-05-19 06:47:16 +02:00
b39996616c
* renderer batching * initialization and rendering performance optimized * insertMany api method added * Update index.html * rm old method * upd changelog * upd paragraph * paste tests fixed * api blocks tests fixed * backspace event tests fixed * async issues in tests fixed * eslint * stub block added, tests added * eslint * eslint * add test for insertMany() * Update package.json
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import type EditorJS from '../../../types/index';
|
|
import { OutputData } from '../../../types/index';
|
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
describe('Output sanitization', () => {
|
|
context('Output should save inline formatting', () => {
|
|
it('should save initial formatting for paragraph', () => {
|
|
cy.createEditor({
|
|
data: {
|
|
blocks: [ {
|
|
type: 'paragraph',
|
|
data: { text: '<b>Bold text</b>' },
|
|
} ],
|
|
},
|
|
})
|
|
.then(async editor => {
|
|
cy.wrap<OutputData>(await editor.save())
|
|
.then((output) => {
|
|
const boldText = output.blocks[0].data.text;
|
|
|
|
expect(boldText).to.eq('<b>Bold text</b>');
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should save formatting for paragraph', () => {
|
|
cy.createEditor({})
|
|
.as('editorInstance');
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.get('div.ce-block')
|
|
.click()
|
|
.type('This text should be bold.{selectall}');
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.get('button.ce-inline-tool--bold')
|
|
.click();
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.get('div.ce-block')
|
|
.click();
|
|
|
|
cy.get<EditorJS>('@editorInstance')
|
|
.then(async editorInstance => {
|
|
cy.wrap(await editorInstance.save())
|
|
.then((output) => {
|
|
const text = output.blocks[0].data.text;
|
|
|
|
expect(text).to.match(/<b>This text should be bold\.(<br>)?<\/b>/);
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should save formatting for paragraph on paste', () => {
|
|
cy.createEditor({})
|
|
.as('editorInstance');
|
|
|
|
cy.get('[data-cy=editorjs]')
|
|
.get('div.ce-block')
|
|
.paste({
|
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
'text/html': '<p>Text</p><p><b>Bold text</b></p>',
|
|
});
|
|
|
|
cy.get<EditorJS>('@editorInstance')
|
|
.then(async editorInstance => {
|
|
cy.wrap<OutputData>(await editorInstance.save())
|
|
.then((output) => {
|
|
const boldText = output.blocks[1].data.text;
|
|
|
|
expect(boldText).to.eq('<b>Bold text</b>');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|