forked from codex-team/editor.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toolbar-api): method for toggling toolbox (codex-team#2332)
* 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>
- Loading branch information
1 parent
707ff72
commit 0491155
Showing
5 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* 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(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters