editor.js/test/cypress/support/utils/createEditorWithTextBlocks.ts
Peter 3d01be4a69
fix(types): tools export types added (#2802)
* fix types export

* lint

* changelog

* tests fixed

* fix tests imports

* lint tests

* upd submodule

* Update yarn.lock

* rename wrapper to factory

* Update package.json

* rename to adapters

* Update tools.d.ts

* BlockTool -> BlockToolAdapter etc

* Update nested-list

* Update collection.ts
2024-08-09 18:04:57 +03:00

23 lines
693 B
TypeScript

import type { EditorConfig } from '../../../../types/index';
import Chainable = Cypress.Chainable;
import type EditorJS from '../../../../types/index';
/**
* Creates Editor instance with list of Paragraph blocks of passed texts
*
* @param textBlocks - list of texts for Paragraph blocks
* @param editorConfig - config to pass to the editor
*/
export function createEditorWithTextBlocks(textBlocks: string[], editorConfig?: Omit<EditorConfig, 'data'>): Chainable<EditorJS> {
return cy.createEditor(Object.assign(editorConfig || {}, {
data: {
blocks: textBlocks.map((text) => ({
type: 'paragraph',
data: {
text,
},
})),
},
}));
}