diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/api.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/api.tests.js index cc4c8ad772b9..9dc72fe92981 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/api.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/api.tests.js @@ -656,6 +656,57 @@ testModule('API', moduleConfig, () => { assert.strictEqual(secondConverter.toHtml.callCount, 1); assert.strictEqual(secondConverter.fromHtml.callCount, 1); }); + + test('The converter methods get the correct parameters', function(assert) { + const converter = { + toHtml: (value) => { + assert.strictEqual(value, 'new value'); + + return value; + }, + fromHtml: (value) => { + assert.strictEqual(value, '

new value

'); + + return value; + }, + }; + + this.options = { converter }; + + this.createEditor(); + + this.instance.option('value', 'new value'); + }); + + test('toHtml changed value correctly', function(assert) { + const converter = { + toHtml: () => { + return '

NEW VALUE

'; + }, + }; + this.options = { converter }; + + this.createEditor(); + + this.instance.option('value', 'new value'); + + assert.strictEqual(this.instance.option('value'), '

NEW VALUE

'); + }); + + test('fromHtml changed value correctly', function(assert) { + const converter = { + fromHtml: () => { + return '**NEW VALUE**'; + }, + }; + this.options = { converter }; + + this.createEditor(); + + this.instance.option('value', 'new value'); + + assert.strictEqual(this.instance.option('value'), '**NEW VALUE**'); + }); }); }); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/valueRendering.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/valueRendering.tests.js index e48db94e758f..45afa1899aa2 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/valueRendering.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/valueRendering.tests.js @@ -649,4 +649,20 @@ export default function() { }); }); }); + + testModule('converter option', () => { + test('value from toHtml must match the markup value', function(assert) { + const instance = $('#htmlEditor').dxHtmlEditor({ + converter: { + toHtml: () => '

Hi!

Test

', + }, + }).dxHtmlEditor('instance'); + + instance.option('value', 'new value'); + + const markup = instance.$element().find(`.${CONTENT_CLASS}`).html(); + + assert.strictEqual(markup, '

Hi!

Test

'); + }); + }); }