mirror of
https://github.com/codex-team/editor.js
synced 2024-06-10 09:52:36 +02:00
Add testcase for missing toolbox title
This commit is contained in:
parent
93860de2a0
commit
7cc04c015c
|
@ -1,17 +1,31 @@
|
||||||
import Header from '@editorjs/header';
|
import Header from '@editorjs/header';
|
||||||
|
import { ToolboxConfig } from '../../../types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tool class allowing to test case when capitalized tool name is used as translation key if toolbox title is missing
|
||||||
|
*/
|
||||||
|
class TestTool {
|
||||||
|
/**
|
||||||
|
* Returns toolbox config without title
|
||||||
|
*/
|
||||||
|
public static get toolbox(): ToolboxConfig {
|
||||||
|
return {
|
||||||
|
title: '',
|
||||||
|
icon: '<svg width="17" height="15" viewBox="0 0 336 276" xmlns="http://www.w3.org/2000/svg"><path d="M291 150V79c0-19-15-34-34-34H79c-19 0-34 15-34 34v42l67-44 81 72 56-29 42 30zm0 52l-43-30-56 30-81-67-66 39v23c0 19 15 34 34 34h178c17 0 31-13 34-29zM79 0h178c44 0 79 35 79 79v118c0 44-35 79-79 79H79c-44 0-79-35-79-79V79C0 35 35 0 79 0z"/></svg>',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
describe('Editor i18n', () => {
|
describe('Editor i18n', () => {
|
||||||
/**
|
context('Toolbox', () => {
|
||||||
* Stores translations for tool names
|
it('should translate tool title in a toolbox', () => {
|
||||||
*/
|
if (this && this.editorInstance) {
|
||||||
const toolNamesDictionary = {
|
this.editorInstance.destroy();
|
||||||
Heading: 'Заголовок',
|
}
|
||||||
};
|
const toolNamesDictionary = {
|
||||||
|
Heading: 'Заголовок',
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
if (this && this.editorInstance) {
|
|
||||||
this.editorInstance.destroy();
|
|
||||||
} else {
|
|
||||||
cy.createEditor({
|
cy.createEditor({
|
||||||
tools: {
|
tools: {
|
||||||
header: Header,
|
header: Header,
|
||||||
|
@ -22,20 +36,49 @@ describe('Editor i18n', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).as('editorInstance');
|
}).as('editorInstance');
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should translate tool title in a toolbox', () => {
|
cy.get('[data-cy=editorjs]')
|
||||||
cy.get('[data-cy=editorjs]')
|
.get('div.ce-block')
|
||||||
.get('div.ce-block')
|
.click();
|
||||||
.click();
|
|
||||||
|
|
||||||
cy.get('[data-cy=editorjs]')
|
cy.get('[data-cy=editorjs]')
|
||||||
.get('div.ce-toolbar__plus')
|
.get('div.ce-toolbar__plus')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
cy.get('[data-cy=editorjs]')
|
cy.get('[data-cy=editorjs]')
|
||||||
.get('div.ce-popover__item[data-item-name=header]')
|
.get('div.ce-popover__item[data-item-name=header]')
|
||||||
.should('contain.text', toolNamesDictionary.Heading);
|
.should('contain.text', toolNamesDictionary.Heading);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should use capitalized tool name as translation key if toolbox title is missing', () => {
|
||||||
|
if (this && this.editorInstance) {
|
||||||
|
this.editorInstance.destroy();
|
||||||
|
}
|
||||||
|
const toolNamesDictionary = {
|
||||||
|
TestTool: 'ТестТул',
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.createEditor({
|
||||||
|
tools: {
|
||||||
|
testTool: TestTool,
|
||||||
|
},
|
||||||
|
i18n: {
|
||||||
|
messages: {
|
||||||
|
toolNames: toolNamesDictionary,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).as('editorInstance');
|
||||||
|
cy.get('[data-cy=editorjs]')
|
||||||
|
.get('div.ce-block')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.get('[data-cy=editorjs]')
|
||||||
|
.get('div.ce-toolbar__plus')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
cy.get('[data-cy=editorjs]')
|
||||||
|
.get('div.ce-popover__item[data-item-name=testTool]')
|
||||||
|
.should('contain.text', toolNamesDictionary.TestTool);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in a new issue