editor.js/test/cypress/tests/tools/ToolsFactory.cy.ts
Taly aafab1d395
Use Vite builder (#2300)
* vite builder initial

* save

* add displayName

* add paragraph from npm

* fix postcss apply

* remove some packages, fix tests

* Update cypress.yml

* remove logs

* remove unused packages

* update path to image

* update

* Update index.html

* Update cypress.yml

* Update cypress.yml

* Update cypress.yml

* remove displayName field

* update names

* Update index.ts

* Update index.ts

* update packages

* remove packages

* postcss preserve: true

* Update index.html

* Update editor-modules.d.ts

* use public dir for static

* Update vite.config.js

* update modules type

* Update CHANGELOG.md
2023-04-13 22:25:29 +03:00

61 lines
1.6 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
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 '@editorjs/paragraph';
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;
});
});
});