本文整理汇总了TypeScript中@ephox/bedrock.UnitTest类的典型用法代码示例。如果您正苦于以下问题:TypeScript UnitTest类的具体用法?TypeScript UnitTest怎么用?TypeScript UnitTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitTest类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
UnitTest.asynctest('browser.tinymce.core.focus.CefFocusTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const viewBlock = ViewBlock();
Theme();
const sCreateInlineEditors = function (html) {
return Step.async(function (done) {
viewBlock.update(html);
EditorManager.init({
selector: '.tinymce',
inline: true,
skin_url: '/project/js/tinymce/skins/lightgray'
}).then(function () {
done();
});
});
};
const sAssertSelection = function (editorIndex, startPath, startOffset, endPath, endOffset) {
return Step.sync(function () {
const editor = EditorManager.get(editorIndex);
const startContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), startPath).getOrDie();
const endContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), endPath).getOrDie();
const rng = editor.selection.getRng();
Assertions.assertDomEq('Should be expected from start container', startContainer, Element.fromDom(rng.startContainer));
Assertions.assertEq('Should be expected from start offset', startOffset, rng.startOffset);
Assertions.assertDomEq('Should be expected end container', endContainer, Element.fromDom(rng.endContainer));
Assertions.assertEq('Should be expected end offset', endOffset, rng.endOffset);
});
};
const sRemoveEditors = Step.sync(function () {
EditorManager.remove();
});
viewBlock.attach();
Pipeline.async({}, [
Logger.t('Focus editors', GeneralSteps.sequence([
sCreateInlineEditors('<div class="tinymce"><p contenteditable="false">a</p></div><div class="tinymce"><p contenteditable="false">b</p></div>'),
Step.sync(function () {
EditorManager.get(0).getBody().focus();
EditorManager.get(1).getBody().focus();
}),
Waiter.sTryUntil('Wait for selection to move', sAssertSelection(1, [0], 0, [0], 0), 10, 3000),
Step.sync(function () {
const caretElm0 = EditorManager.get(0).getBody().querySelector('[data-mce-caret]');
const caretElm1 = EditorManager.get(1).getBody().querySelector('[data-mce-caret]');
Assertions.assertEq('Should not be a caret element present editor 0', false, !!caretElm0);
Assertions.assertEq('Should be a caret element present editor 1', true, !!caretElm1);
}),
sRemoveEditors
]))
], function () {
viewBlock.detach();
success();
}, failure);
});
示例2: function
UnitTest.asynctest('browser.tinymce.plugins.visualblocks.PreviewFormatsTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
VisualBlocksPlugin();
const sWaitForVisualBlocks = function (editor) {
return Waiter.sTryUntil('Wait background css to be applied to first element', Step.sync(function () {
const p = Element.fromDom(editor.getBody().firstChild);
const background = Css.get(p, 'background-image');
Assertions.assertEq('Paragraph should have a url background', true, background.indexOf('url(') === 0);
}), 10, 1000);
};
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
Logger.t('Toggle on/off visualblocks and compute previews', GeneralSteps.sequence([
tinyApis.sExecCommand('mceVisualBlocks'),
sWaitForVisualBlocks(editor),
Step.sync(function () {
Assertions.assertEq('Visual blocks class should exist', true, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
Assertions.assertEq('Should not have a border property', true, editor.formatter.getCssText('h1').indexOf('border:1px dashed') === -1);
}),
tinyApis.sExecCommand('mceVisualBlocks'),
Step.sync(function () {
Assertions.assertEq('Visual blocks class should not exist', false, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
Assertions.assertEq('Should not have a border property', true, editor.formatter.getCssText('h1').indexOf('border:1px dashed') === -1);
Assertions.assertEq('Visual blocks class should still not exist', false, Class.has(Element.fromDom(editor.getBody()), 'mce-visualblocks'));
})
]))
], onSuccess, onFailure);
}, {
plugins: 'visualblocks',
toolbar: 'visualblocks',
visualblocks_content_css: '/project/js/tinymce/plugins/visualblocks/css/visualblocks.css',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例3: function
UnitTest.asynctest('browser.tinymce.core.html.DomParserTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
const schema = Schema({ valid_elements: '*[class|title]' });
const serializer = Serializer({}, schema);
let parser, root;
const countNodes = function (node, counter?) {
let sibling;
if (!counter) {
counter = {};
}
if (node.name in counter) {
counter[node.name]++;
} else {
counter[node.name] = 1;
}
for (sibling = node.firstChild; sibling; sibling = sibling.next) {
countNodes(sibling, counter);
}
return counter;
};
schema.addValidChildren('+body[style]');
suite.test('Parse element', function () {
let parser, root;
parser = DomParser({}, schema);
root = parser.parse('<B title="title" class="class">test</B>');
LegacyUnit.equal(serializer.serialize(root), '<b class="class" title="title">test</b>', 'Inline element');
LegacyUnit.equal(root.firstChild.type, 1, 'Element type');
LegacyUnit.equal(root.firstChild.name, 'b', 'Element name');
LegacyUnit.deepEqual(
root.firstChild.attributes, [{ name: 'title', value: 'title' },
{ name: 'class', value: 'class' }],
'Element attributes'
);
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'b': 1, '#text': 1 }, 'Element attributes (count)');
parser = DomParser({}, schema);
root = parser.parse(' \t\r\n <SCRIPT> \t\r\n a < b > \t\r\n </S' + 'CRIPT> \t\r\n ');
LegacyUnit.equal(serializer.serialize(root), '<script> \t\r\n a < b > \t\r\n </s' + 'cript>', 'Retain code inside SCRIPT');
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'script': 1, '#text': 1 }, 'Retain code inside SCRIPT (count)');
});
suite.test('Whitespace', function () {
parser = DomParser({}, schema);
root = parser.parse(' \t\r\n <B> \t\r\n test \t\r\n </B> \t\r\n ');
LegacyUnit.equal(serializer.serialize(root), ' <b> test </b> ', 'Redundant whitespace (inline element)');
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'b': 1, '#text': 3 }, 'Redundant whitespace (inline element) (count)');
parser = DomParser({}, schema);
root = parser.parse(' \t\r\n <P> \t\r\n test \t\r\n </P> \t\r\n ');
LegacyUnit.equal(serializer.serialize(root), '<p>test</p>', 'Redundant whitespace (block element)');
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'p': 1, '#text': 1 }, 'Redundant whitespace (block element) (count)');
parser = DomParser({}, schema);
root = parser.parse(' \t\r\n <SCRIPT> \t\r\n test \t\r\n </S' + 'CRIPT> \t\r\n ');
LegacyUnit.equal(
serializer.serialize(root),
'<script> \t\r\n test \t\r\n </s' + 'cript>',
'Whitespace around and inside SCRIPT'
);
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'script': 1, '#text': 1 }, 'Whitespace around and inside SCRIPT (count)');
parser = DomParser({}, schema);
root = parser.parse(' \t\r\n <STYLE> \t\r\n test \t\r\n </STYLE> \t\r\n ');
LegacyUnit.equal(serializer.serialize(root), '<style> \t\r\n test \t\r\n </style>', 'Whitespace around and inside STYLE');
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'style': 1, '#text': 1 }, 'Whitespace around and inside STYLE (count)');
parser = DomParser({}, schema);
root = parser.parse('<ul>\n<li>Item 1\n<ul>\n<li>\n \t Indented \t \n</li>\n</ul>\n</li>\n</ul>\n');
LegacyUnit.equal(
serializer.serialize(root),
'<ul><li>Item 1<ul><li>Indented</li></ul></li></ul>',
'Whitespace around and inside blocks (ul/li)'
);
LegacyUnit.deepEqual(countNodes(root), { 'body': 1, 'li': 2, 'ul': 2, '#text': 2 }, 'Whitespace around and inside blocks (ul/li) (count)');
parser = DomParser({}, Schema({ invalid_elements: 'hr,br' }));
root = parser.parse(
'\n<hr />\n<br />\n<div>\n<hr />\n<br />\n<img src="file.gif" data-mce-src="file.gif" />\n<hr />\n<br />\n</div>\n<hr />\n<br />\n'
);
LegacyUnit.equal(
serializer.serialize(root),
'<div><img src="file.gif" data-mce-src="file.gif" /></div>',
'Whitespace where SaxParser will produce multiple whitespace nodes'
);
LegacyUnit.deepEqual(
countNodes(root),
{ body: 1, div: 1, img: 1 },
'Whitespace where SaxParser will produce multiple whitespace nodes (count)'
);
//.........这里部分代码省略.........
示例4: function
import { Assertions, Pipeline } from '@ephox/agar';
import { TinyLoader } from '@ephox/mcagar';
import Theme from 'tinymce/themes/modern/Theme';
import { UnitTest } from '@ephox/bedrock';
UnitTest.asynctest('browser.tinymce.core.EditorForcedSettingsTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
Theme();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, [
Assertions.sAssertEq('Validate should always be true', true, editor.settings.validate),
Assertions.sAssertEq('Validate should true since inline was set to true', true, editor.settings.content_editable)
], onSuccess, onFailure);
}, {
skin_url: '/project/js/tinymce/skins/lightgray',
// Setting exposed as another forced setting
inline: true,
// Settings that are to be forced
validate: false
}, success, failure);
});
示例5: function
UnitTest.asynctest('browser.tinymce.plugins.textcolor.TextcolorSanityTest.js', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
TextcolorPlugin();
const forecolorStruct = ApproxStructure.build(function (s, str) {
return s.element('body', {
children: [
s.element('p', {
children: [
s.element('span', {
styles: {
'color': str.is(Env.ie && Env.ie <= 11 ? '#0000ff' : 'rgb(0, 0, 255)'),
'font-size': str.is('24pt')
}
}),
s.text(str.is(' test'))
]
})
]
});
});
const backcolorStruct = ApproxStructure.build(function (s, str) {
return s.element('body', {
children: [
s.element('p', {
children: [
s.element('span', {
styles: {
'background-color': str.is('rgb(204, 153, 255)'),
'font-size': str.is('24pt')
}
}),
s.text(str.is(' test'))
]
})
]
});
});
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
Pipeline.async({}, [
// forecolor test
tinyApis.sSetContent('hello test'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 5),
tinyUi.sClickOnToolbar('click forecolor', 'div[aria-label="Text color"] > button.mce-open'),
tinyUi.sClickOnUi('click green color', 'div[data-mce-color="#00FF00"]:first'),
tinyUi.sClickOnToolbar('click fontsize', 'div[aria-label="Font Sizes"] > button'),
tinyUi.sClickOnUi('click 24pt', 'div.mce-floatpanel span.mce-text:contains("24pt")'),
tinyUi.sClickOnToolbar('click forecolor again', 'div[aria-label="Text color"] > button.mce-open'),
tinyUi.sClickOnUi('click blue color', 'div[data-mce-color="#0000FF"]:first'),
tinyApis.sAssertContentStructure(forecolorStruct),
// backcolor test
tinyApis.sSetContent('hello test'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 5),
tinyUi.sClickOnToolbar('click backcolor', 'div[aria-label="Background color"] > button.mce-open'),
tinyUi.sClickOnUi('click green color', 'div[data-mce-color="#00FF00"]:last'),
tinyUi.sClickOnToolbar('click fontsize', 'div[aria-label="Font Sizes"] > button'),
tinyUi.sClickOnUi('click 24pt', 'div.mce-floatpanel span.mce-text:contains("24pt")'),
tinyUi.sClickOnToolbar('click backcolor again', 'div[aria-label="Background color"] > button.mce-open'),
tinyUi.sClickOnUi('click a nice purple color', 'div[data-mce-color="#CC99FF"]:last'),
tinyApis.sAssertContentStructure(backcolorStruct)
], onSuccess, onFailure);
}, {
plugins: 'textcolor',
toolbar: 'forecolor backcolor fontsizeselect',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例6: Plugin
UnitTest.asynctest('browser.tinymce.plugins.autosave.AutoSavePluginTest', (success, failure) => {
const suite = LegacyUnit.createSuite();
Plugin();
Theme();
suite.test('isEmpty true', function (editor) {
LegacyUnit.equal(editor.plugins.autosave.isEmpty(''), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty(' '), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('\t\t\t'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p id="x"></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p> </p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>\t</p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br><br></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /><br /></p>'), true);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" /></p>'), true);
});
suite.test('isEmpty false', function (editor) {
LegacyUnit.equal(editor.plugins.autosave.isEmpty('X'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty(' X'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('\t\t\tX'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p> X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p>\tX</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br>X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br />X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" />X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br><br>X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br /><br />X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" />X</p>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<h1></h1>'), false);
LegacyUnit.equal(editor.plugins.autosave.isEmpty('<img src="x" />'), false);
});
suite.test('hasDraft/storeDraft/restoreDraft', function (editor) {
LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);
editor.setContent('X');
editor.undoManager.add();
editor.plugins.autosave.storeDraft();
LegacyUnit.equal(editor.plugins.autosave.hasDraft(), true);
editor.setContent('Y');
editor.undoManager.add();
editor.plugins.autosave.restoreDraft();
LegacyUnit.equal(editor.getContent(), '<p>X</p>');
editor.plugins.autosave.removeDraft();
});
suite.test('recognises location hash change', function (editor) {
LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);
editor.setContent('X');
editor.undoManager.add();
editor.plugins.autosave.storeDraft();
window.location.hash = 'test' + Math.random().toString(36).substring(7);
LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);
history.replaceState('', document.title, window.location.pathname + window.location.search);
});
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure);
}, {
plugins: 'autosave',
indent: false,
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例7: function
UnitTest.asynctest('browser.tinymce.core.CaretContainerRemoveTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const viewBlock = ViewBlock();
if (!Env.ceFalse) {
return;
}
const getRoot = function () {
return viewBlock.get();
};
const setupHtml = function (html) {
viewBlock.update(html);
};
const sTestRemove = Logger.t(
'Remove',
Step.sync(function () {
setupHtml('<span contentEditable="false">1</span>');
CaretContainer.insertInline(getRoot().firstChild, true);
Assertions.assertEq('Should be inline container', true, CaretContainer.isCaretContainerInline(getRoot().firstChild));
CaretContainerRemove.remove(getRoot().firstChild);
Assertions.assertEq('Should not be inline container', false, CaretContainer.isCaretContainerInline(getRoot().firstChild));
})
);
const sTestRemoveAndRepositionBlockAtOffset = Logger.t(
'removeAndReposition block in same parent at offset',
Step.sync(function () {
setupHtml('<span contentEditable="false">1</span>');
CaretContainer.insertBlock('p', getRoot().firstChild, true);
Assertions.assertEq('Should be block container', true, CaretContainer.isCaretContainerBlock(getRoot().firstChild));
const pos = CaretContainerRemove.removeAndReposition(getRoot().firstChild, CaretPosition(getRoot(), 0));
Assertions.assertEq('Should be unchanged offset', 0, pos.offset());
Assertions.assertDomEq('Should be unchanged container', Element.fromDom(getRoot()), Element.fromDom(pos.container()));
Assertions.assertEq('Should not be block container', false, CaretContainer.isCaretContainerBlock(getRoot().firstChild));
})
);
const sTestRemoveAndRepositionBeforeOffset = Logger.t(
'removeAndReposition block in same parent before offset',
Step.sync(function () {
setupHtml('<span contentEditable="false">1</span><span contentEditable="false">2</span>');
CaretContainer.insertBlock('p', getRoot().childNodes[1], true);
Assertions.assertEq('Should be block container', true, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1]));
const pos = CaretContainerRemove.removeAndReposition(getRoot().childNodes[1], CaretPosition(getRoot(), 0));
Assertions.assertEq('Should be unchanged offset', 0, pos.offset());
Assertions.assertDomEq('Should be unchanged container', Element.fromDom(getRoot()), Element.fromDom(pos.container()));
Assertions.assertEq('Should not be block container', false, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1]));
})
);
const sTestRemoveAndRepositionAfterOffset = Logger.t(
'removeAndReposition block in same parent after offset',
Step.sync(function () {
setupHtml('<span contentEditable="false">1</span><span contentEditable="false">2</span>');
CaretContainer.insertBlock('p', getRoot().childNodes[1], true);
Assertions.assertEq('Should be block container', true, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1]));
const pos = CaretContainerRemove.removeAndReposition(getRoot().childNodes[1], CaretPosition(getRoot(), 3));
Assertions.assertEq('Should be changed offset', 2, pos.offset());
Assertions.assertDomEq('Should be unchanged container', Element.fromDom(getRoot()), Element.fromDom(pos.container()));
Assertions.assertEq('Should not be block container', false, CaretContainer.isCaretContainerBlock(getRoot().childNodes[1]));
})
);
viewBlock.attach();
Pipeline.async({}, [
sTestRemove,
sTestRemoveAndRepositionBlockAtOffset,
sTestRemoveAndRepositionBeforeOffset,
sTestRemoveAndRepositionAfterOffset
], function () {
viewBlock.detach();
success();
}, failure);
});
示例8: function
UnitTest.asynctest('browser.tinymce.plugins.template.TemplateSanityTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
TemplatePlugin();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
Logger.t('test basic template insertion', GeneralSteps.sequence([
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<strong>c</strong>' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p><strong>c</strong></p>')
])),
Logger.t('test basic content replacement', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p>{$name} {$email}</p>' }]),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester', email: 'test@test.com' }),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p>Tester test@test.com</p>')
])),
Logger.t('test loading in snippet from other file', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', url: '/project/src/plugins/template/test/html/test_template.html' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
Chain.asStep({}, [
tinyUi.cWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
UiFinder.cWaitForState('iframe is loaded', 'iframe', function (elm) {
const iframeDoc = elm.dom().contentDocument || elm.dom().contentWindow.document;
return iframeDoc.body.firstChild !== null;
})
]),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p><em>this is external</em></p>')
])),
Logger.t('test command', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester' }),
tinyApis.sExecCommand('mceInsertTemplate', '<p>{$name}</p>'),
tinyApis.sAssertContent('<p>Tester</p>')
]))
], onSuccess, onFailure);
}, {
plugins: 'template',
toolbar: 'template',
indent: false,
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例9: function
import SpellcheckerPlugin from 'tinymce/plugins/spellchecker/Plugin';
import ModernTheme from 'tinymce/themes/modern/Theme';
import { UnitTest } from '@ephox/bedrock';
UnitTest.asynctest('browser.tinymce.plugins.spellchecker.SpellcheckerTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
SpellcheckerPlugin();
const sCheckButtonType = function (editor, expected) {
return Step.sync(function () {
const button = editor.buttons.spellchecker;
RawAssertions.assertEq('should have same type', expected, button.type);
});
};
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, [
sCheckButtonType(editor, 'button')
], onSuccess, onFailure);
}, {
plugins: 'spellchecker',
toolbar: 'spellchecker',
spellchecker_languages: 'English=en',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例10: LinkPlugin
UnitTest.asynctest('browser.tinymce.plugins.link.ImageFigureLinkTest', (success, failure) => {
LinkPlugin();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const api = TinyApis(editor);
const sLinkTheSelection = function () {
return Logger.t('Link the selection', TestLinkUi.sInsertLink('http://google.com'));
};
const sUnlinkSelection = function () {
return Logger.t('Unlink the selection', Step.sync(function () {
LinkPluginUtils.unlink(editor);
}));
};
const sAssertPresence = function (selector) {
return Waiter.sTryUntil('Assert element is present',
Assertions.sAssertPresence('Detect presence of the element', selector, TinyDom.fromDom(editor.getBody())),
100, 1000
);
};
Pipeline.async({},
Log.steps('TBA', 'Link: Set content, select and link the selection, assert link is present. Then select and unlink the selection, assert link is not present', [
TestLinkUi.sClearHistory,
api.sSetContent(
'<figure class="image">' +
'<img src="http://moxiecode.cachefly.net/tinymce/v9/images/logo.png" />' +
'<figcaption>TinyMCE</figcaption>' +
'</figure>'
),
api.sSetSelection([0], 0, [0], 0),
sLinkTheSelection(),
sAssertPresence({ 'figure.image > a[href="http://google.com"] > img': 1 }),
api.sSetSelection([0], 0, [0], 0),
sUnlinkSelection(),
sAssertPresence({ 'figure.image > img': 1 }),
TestLinkUi.sClearHistory
])
, onSuccess, onFailure);
}, {
plugins: 'link',
toolbar: 'link',
theme: 'silver',
base_url: '/project/tinymce/js/tinymce',
}, success, failure);
});