Skip to content

Commit 6d1de28

Browse files
author
Ruslan Farkhutdinov
committed
HtmlEditor: Rename isStringInsert & restore mock in tests
1 parent a9f3364 commit 6d1de28

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/devextreme/js/__internal/ui/html_editor/matchers/m_wordLists.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { isString } from '@js/core/utils/type';
2+
13
function getListType(matches) {
24
const prefix = matches[1];
35
return prefix.match(/\S+\./) ? 'ordered' : 'bullet';
@@ -21,10 +23,6 @@ function removeNewLineChar(operations) {
2123
newLineOperation.insert = newLineOperation.insert.trim();
2224
}
2325

24-
function isTextOp(op): boolean {
25-
return typeof op === 'string';
26-
}
27-
2826
const getMatcher = (quill) => {
2927
const Delta = quill.import('delta');
3028
const msStyleAttributeName = quill.MS_LIST_DATA_KEY;
@@ -34,7 +32,7 @@ const getMatcher = (quill) => {
3432

3533
const insertOperation = ops[0];
3634

37-
if (!isTextOp(insertOperation.insert)) {
35+
if (!isString(insertOperation.insert)) {
3836
return delta;
3937
}
4038

packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/multilineIntegration.tests.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,23 @@ export default function() {
7070
test(`editor should not throw error for ${className} class with allowSoftLineBreak (T1292587)`, function(assert) {
7171
const spy = sinon.spy(console, 'error');
7272
const value = `<p class="${className}"><br><br></p>`;
73-
const $element = $('#htmlEditor');
74-
$element.dxHtmlEditor({
75-
value
76-
}).dxHtmlEditor('instance');
7773

78-
assert.strictEqual(spy.called, false, 'No console error was thrown');
79-
spy.restore();
74+
try {
75+
$('#htmlEditor').dxHtmlEditor({ value }).dxHtmlEditor('instance');
76+
77+
assert.strictEqual(spy.called, false, 'No console error was thrown');
78+
} finally {
79+
spy.restore();
80+
}
8081
});
8182

8283
test(`editor should preserve double <br> in list paragraph for ${className} class (T1292587)`, function(assert) {
8384
const value = `<p class="${className}"><br><br></p>`;
84-
const $element = $('#htmlEditor');
85-
$element.dxHtmlEditor({
85+
const htmlEditor = $('#htmlEditor').dxHtmlEditor({
8686
value
8787
}).dxHtmlEditor('instance');
88-
const markup = $element.find(`.${CONTENT_CLASS}`).html();
88+
89+
const markup = htmlEditor.option('value');
8990
const $markup = $('<div>').html(markup);
9091

9192
assert.strictEqual($markup.find('br').length, 2, 'Two soft breaks preserved');

0 commit comments

Comments
 (0)