import { Pipeline } from '@ephox/agar'; import { UnitTest } from '@ephox/bedrock'; import { LegacyUnit, TinyLoader } from '@ephox/mcagar'; import Plugin from 'tinymce/plugins/legacyoutput/Plugin'; import Theme from 'tinymce/themes/modern/Theme'; UnitTest.asynctest( 'browser.tinymce.plugins.legacyoutput.LegacyOutputPluginTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; const suite = LegacyUnit.createSuite(); Plugin(); Theme(); suite.test('Font color', function (editor) { editor.focus(); editor.setContent('
text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('forecolor', false, '#FF0000'); LegacyUnit.equal(editor.getContent().toLowerCase(), 'text
'); }); suite.test('Font size', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('fontsize', false, 7); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Font face', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('fontname', false, 'times'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Bold', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('bold'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Italic', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('italic'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Underline', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('underline'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Strikethrough', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('strikethrough'); LegacyUnit.equal(editor.getContent(), 'text
text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('justifyleft'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Justifycenter', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('justifycenter'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Justifyright', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('justifyright'); LegacyUnit.equal(editor.getContent(), 'text
'); }); suite.test('Justifyfull', function (editor) { editor.setContent('text
'); LegacyUnit.setSelection(editor, 'p', 0, 'p', 4); editor.execCommand('justifyfull'); LegacyUnit.equal(editor.getContent(), 'text
'); }); TinyLoader.setup(function (editor, onSuccess, onFailure) { Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure); }, { plugins: 'legacyoutput', indent: false, skin_url: '/project/js/tinymce/skins/lightgray' }, success, failure); } );