mirror of
https://github.com/codex-team/editor.js
synced 2024-05-07 17:06:48 +02:00
2d89105670
* Add internal wrappers for tools classes * FIx lint * Change tools collections to map * Apply some more refactoring * Make tool instance private field * Add some docs * Fix eslint * Basic implementation for Block Tunes * Small fix for demo * Review changes * Fix * Add common tunes and ToolsCollection class * Fixes after review * Rename tools collections * Readonly fix * Some fixes after review * Apply suggestions from code review Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Fixes after review * Add docs and changelog * Update docs/block-tunes.md Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Apply suggestions from code review Co-authored-by: Peter Savchenko <specc.dev@gmail.com> * Update src/components/block/index.ts Co-authored-by: Murod Khaydarov <murod.haydarov@gmail.com> * [Dev] Tools utils tests (#1602) * Add tests for tools utils and coverage report * Fix eslint * Adjust test * Add more tests * Update after code review * Fix test & bump version Co-authored-by: Peter Savchenko <specc.dev@gmail.com> Co-authored-by: Murod Khaydarov <murod.haydarov@gmail.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import LinkInlineTool from '../../../../src/components/inline-tools/inline-tool-link';
|
|
import MoveUpTune from '../../../../src/components/block-tunes/block-tune-move-up';
|
|
import ToolsFactory from '../../../../src/components/tools/factory';
|
|
import InlineTool from '../../../../src/components/tools/inline';
|
|
import BlockTool from '../../../../src/components/tools/block';
|
|
import BlockTune from '../../../../src/components/tools/tune';
|
|
import Paragraph from '../../../../src/tools/paragraph/dist/bundle';
|
|
|
|
describe('ToolsFactory', (): void => {
|
|
let factory;
|
|
const config = {
|
|
paragraph: {
|
|
class: Paragraph,
|
|
},
|
|
link: {
|
|
class: LinkInlineTool,
|
|
},
|
|
moveUp: {
|
|
class: MoveUpTune,
|
|
},
|
|
};
|
|
|
|
beforeEach((): void => {
|
|
factory = new ToolsFactory(
|
|
config,
|
|
{
|
|
placeholder: 'Placeholder',
|
|
defaultBlock: 'paragraph',
|
|
} as any,
|
|
{} as any
|
|
);
|
|
});
|
|
|
|
context('.get', (): void => {
|
|
it('should return appropriate tool object', (): void => {
|
|
const tool = factory.get('link');
|
|
|
|
expect(tool.name).to.be.eq('link');
|
|
});
|
|
|
|
it('should return InlineTool object for inline tool', (): void => {
|
|
const tool = factory.get('link');
|
|
|
|
expect(tool instanceof InlineTool).to.be.true;
|
|
});
|
|
|
|
it('should return BlockTool object for block tool', (): void => {
|
|
const tool = factory.get('paragraph');
|
|
|
|
expect(tool instanceof BlockTool).to.be.true;
|
|
});
|
|
|
|
it('should return BlockTune object for tune', (): void => {
|
|
const tool = factory.get('moveUp');
|
|
|
|
expect(tool instanceof BlockTune).to.be.true;
|
|
});
|
|
});
|
|
});
|