Wordpress/tests/qunit/editor/plugins/spellchecker.html
Andrew Ozz ce2dcccf86 Incorporate the TinyMCE tests into our JS tests:
- Modified the original tests so TinyMCE can be loaded from /src/wp-includes/js/tinymce.
- Added "WP" option to the UI to select only tests relevant to our integration (excludes most of the default plugins tests).
- Added tests for obsolete HTML elements and attributes (html4 back-compat).
See #27014.

git-svn-id: https://develop.svn.wordpress.org/trunk@27155 602fd350-edb4-49c9-b593-d223f7449a82
2014-02-10 01:11:25 +00:00

109 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Unit tests for spellchecker plugin</title>
<meta http-eqiv="X-UA-Compatible" content="IE-edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="../js/qunit/reporter.js"></script>
<script src="../js/utils.js"></script>
<script src="../js/tinymce_loader.js"></script>
<script>
var editors = {}, awaitingInit=2;
initTinyMCE({
instance_name: 'no_lang'
});
initTinyMCE({
instance_name: 'one_lang',
spellchecker_languages: 'English=en'
});
initTinyMCE({
instance_name: 'many_lang',
spellchecker_languages: 'English=en,French=fr,German=de'
});
QUnit.config.reorder = false;
QUnit.config.autostart = false;
module("tinymce.Spellchecker", {
autostart: false
});
// Default spellchecker language should match editor language
test('Check default language', function() {
var mainLanguage = editors.no_lang.settings.language || 'en';
equal(editors.no_lang.settings.spellchecker_language, mainLanguage);
});
// Spellchecker button may include a language menu
// When no languages are specified, the default list of languages should be
// used, matching the list in the old TinyMCE 3 spellchecker plugin.
test('Check spellcheck button is a splitbutton (no languages)', function() {
var spellcheckButton = editors.no_lang.buttons.spellchecker;
equal(spellcheckButton.type, 'splitbutton');
});
// When exactly one spellchecker language is specified, there's no need to
// display a selection menu.
test('Check spellcheck button is a normal button (one language)', function() {
var spellcheckButton = editors.one_lang.buttons.spellchecker;
equal(spellcheckButton.type, 'button');
});
// When more than one spellchecker language is specified, a selection menu
// should be provided to choose between them.
test('Check spellcheck button is a splitbutton (many languages)', function() {
var spellcheckButton = editors.many_lang.buttons.spellchecker;
equal(spellcheckButton.type, 'splitbutton');
});
function initTinyMCE(args) {
var instance_name = args.instance_name;
var init_args = {
mode: "exact",
plugins: "spellchecker",
selector: '#' + instance_name,
add_unload_trigger: false,
disable_nodechange: true,
toolbar1: "spellchecker",
init_instance_callback: function(ed) {
editors[instance_name] = ed;
checkEditorsReady();
}
};
if (args.spellchecker_languages) {
init_args.spellchecker_languages = args.spellchecker_languages;
}
tinymce.init(init_args);
}
function checkEditorsReady() {
awaitingInit--;
if (awaitingInit == 0) {
window.setTimeout(function() {
QUnit.start();
}, 0);
}
}
</script>
</head>
<body>
<h1 id="qunit-header">Unit tests for spellchecker plugin</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<textarea id="no_lang"></textarea>
<a href="javascript:;" onclick="alert(tinymce.get('no_lang').getContent({format: 'raw'}));return false;">[Get raw]</a>
<textarea id="one_lang"></textarea>
<a href="javascript:;" onclick="alert(tinymce.get('one_lang').getContent({format: 'raw'}));return false;">[Get raw]</a>
<textarea id="many_lang"></textarea>
<a href="javascript:;" onclick="alert(tinymce.get('many_lang').getContent({format: 'raw'}));return false;">[Get raw]</a>
</body>
</html>