import { GeneralSteps, Pipeline, Step } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { TinyApis, TinyLoader } from '@ephox/mcagar'; import Unlink from 'tinymce/themes/inlite/alien/Unlink'; import Theme from 'tinymce/themes/inlite/Theme'; UnitTest.asynctest('browser.alien.UnlinkTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; Theme(); const sUnlinkSelection = function (editor) { return Step.sync(function () { Unlink.unlinkSelection(editor); }); }; TinyLoader.setup(function (editor, onSuccess, onFailure) { const tinyApis = TinyApis(editor); const sAssertUnlink = function (inputHtml, startPath, startOffset, finishPath, finishOffset, expectedHtml) { return GeneralSteps.sequence([ tinyApis.sSetContent(inputHtml), tinyApis.sSetSelection(startPath, startOffset, finishPath, finishOffset), sUnlinkSelection(editor), tinyApis.sAssertContent(expectedHtml) ]); }; Pipeline.async({}, [ sAssertUnlink('
', [0, 0, 0], 0, [0, 0, 0], 1, 'a
'), sAssertUnlink('ab
', [0, 0, 0], 0, [0, 1], 1, 'ab
'), sAssertUnlink('b', [0, 0, 0], 0, [0, 0, 0], 1, '
a
\n'), sAssertUnlink('b', [0, 0, 0], 0, [1, 0, 0], 1, '
a
\nb
') ], onSuccess, onFailure); }, { inline: true, theme: 'inlite', skin_url: '/project/js/tinymce/skins/lightgray' }, success, failure); });