mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 18:03:25 +02:00
0491155e33
* Expose toolbox control method * Add test for toolbox * rename method to toggleToolbox * add missing test case * Add changelog * remove eslint rule * Update changelog Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * fix linter problems --------- Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
87 lines
2.1 KiB
TypeScript
87 lines
2.1 KiB
TypeScript
/**
|
|
* There will be described test cases of 'api.toolbar.*' API
|
|
*/
|
|
import EditorJS from '../../../../types';
|
|
|
|
describe('api.toolbar', () => {
|
|
/**
|
|
* api.toolbar.openToolbox(openingState?: boolean)
|
|
*/
|
|
const firstBlock = {
|
|
id: 'bwnFX5LoX7',
|
|
type: 'paragraph',
|
|
data: {
|
|
text: 'The first block content mock.',
|
|
},
|
|
};
|
|
const editorDataMock = {
|
|
blocks: [
|
|
firstBlock,
|
|
],
|
|
};
|
|
|
|
beforeEach(function () {
|
|
cy.createEditor({
|
|
data: editorDataMock,
|
|
readOnly: false,
|
|
}).as('editorInstance');
|
|
});
|
|
|
|
afterEach(function () {
|
|
if (this.editorInstance) {
|
|
this.editorInstance.destroy();
|
|
}
|
|
});
|
|
|
|
describe('*.toggleToolbox()', () => {
|
|
const isToolboxVisible = (): void => {
|
|
cy.get('[data-cy=editorjs]').find('div.ce-toolbox')
|
|
.then((toolbox) => {
|
|
if (toolbox.is(':visible')) {
|
|
assert.isOk(true, 'Toolbox visible');
|
|
} else {
|
|
assert.isNotOk(false, 'Toolbox should be visible');
|
|
}
|
|
});
|
|
};
|
|
|
|
const isToolboxNotVisible = (): void => {
|
|
cy.get('[data-cy=editorjs]').find('div.ce-toolbox')
|
|
.then((toolbox) => {
|
|
if (!toolbox.is(':visible')) {
|
|
assert.isOk(true, 'Toolbox not visible');
|
|
} else {
|
|
assert.isNotOk(false, 'Toolbox should not be visible');
|
|
}
|
|
});
|
|
};
|
|
|
|
it('should open the toolbox', function () {
|
|
cy.get<EditorJS>('@editorInstance').then(async function (editor) {
|
|
editor.toolbar.toggleToolbox(true);
|
|
isToolboxVisible();
|
|
});
|
|
});
|
|
|
|
it('should close the toolbox', function () {
|
|
cy.get<EditorJS>('@editorInstance').then(async function (editor) {
|
|
editor.toolbar.toggleToolbox(true);
|
|
|
|
isToolboxVisible();
|
|
|
|
editor.toolbar.toggleToolbox(false);
|
|
isToolboxNotVisible();
|
|
});
|
|
});
|
|
it('should toggle the toolbox', function () {
|
|
cy.get<EditorJS>('@editorInstance').then(async function (editor) {
|
|
editor.toolbar.toggleToolbox();
|
|
isToolboxVisible();
|
|
|
|
editor.toolbar.toggleToolbox();
|
|
isToolboxNotVisible();
|
|
});
|
|
});
|
|
});
|
|
});
|