From 78de2732479177e0d714b40900cca171a57bc0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 10 Oct 2024 20:19:38 +0200 Subject: [PATCH] feat(htmleditor): Add runtime tests --- .../htmlEditorParts/converters.tests.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/converters.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/converters.tests.js index ec30b750072a..88598f28cab8 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/converters.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.htmlEditor/htmlEditorParts/converters.tests.js @@ -272,5 +272,34 @@ testModule('converter option', () => { assert.ok(true, 'there is no error'); } }); + + test('coverter should be replaced in runtime', function(assert) { + const toHtmlFirstStub = sinon.stub(); + const fromHtmlFirstStub = sinon.stub(); + const toHtmlSecondStub = sinon.stub(); + const fromHtmlSecondStub = sinon.stub(); + + const firstConverter = { + toHtml: toHtmlFirstStub, + fromHtml: fromHtmlFirstStub, + }; + + const secondConverter = { + toHtml: toHtmlSecondStub, + fromHtml: fromHtmlSecondStub, + }; + + const instance = $('#htmlEditor').dxHtmlEditor({ + converter: firstConverter, + }).dxHtmlEditor('instance'); + + instance.option('converter', secondConverter); + instance.option('value', 'new value'); + + assert.strictEqual(toHtmlFirstStub.callCount, 0); + assert.strictEqual(fromHtmlFirstStub.callCount, 0); + assert.strictEqual(toHtmlSecondStub.callCount, 1); + assert.strictEqual(fromHtmlSecondStub.callCount, 1); + }); }); });