Wordpress/tests/qunit/editor/tinymce/ui/Selector.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

149 lines
4.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>ui.Selector Test Suite</title>
<link type="text/css" rel="stylesheet" href="../../../../../src/wp-includes/js/tinymce/skins/lightgray/skin.min.css" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="css/ui-overrides.css" type="text/css" />
<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 type="text/javascript">
var panel;
QUnit.config.autostart = false;
module("ui.Selector");
window.onload = function() {
panel = tinymce.ui.Factory.create({
type: 'panel',
items: [
{type: 'button', name: 'button1', text: 'button1', classes: 'class1', disabled: true},
{type: 'button', name: 'button2', classes: 'class1 class2'},
{type: 'button', name: 'button3', classes: 'class2 class1 class3'},
{type: 'buttongroup', name: 'buttongroup1', items: [
{type: 'button', name: 'button4'},
{type: 'button', name: 'button5'},
{type: 'button', name: 'button6'}
]},
{type: 'buttongroup', name: 'buttongroup2', items: [
{type: 'button', name: 'button7'},
{type: 'button', name: 'button8'},
{type: 'button', name: 'button9'}
]},
{type: 'toolbar', name: 'toolbar1', items: [
{type: 'buttongroup', name: 'buttongroup3', items: [
{type: 'button', name: 'button10', disabled: true},
{type: 'button', name: 'button11'},
{type: 'button', name: 'button12', classes: 'class4'}
]}
]}
]
}).renderTo(document.getElementById('view'));
QUnit.start();
};
test("Basic", function() {
var matches;
matches = panel.find('button');
equal(matches.length, 12);
equal(matches[0].type, 'button');
equal(panel.find('Button').length, 12);
equal(panel.find('buttongroup').length, 3);
equal(panel.find('buttongroup button').length, 9);
equal(panel.find('toolbar buttongroup button').length, 3);
equal(panel.find('button#button1').length, 1);
equal(panel.find('buttongroup#buttongroup1 button#button4').length, 1);
equal(panel.find('button,button,buttongroup button').length, 12, 'Check unique');
});
test("Classes", function() {
equal(panel.find('button.class1').length, 3);
equal(panel.find('button.class1.class2').length, 2);
equal(panel.find('button.class2.class1').length, 2);
equal(panel.find('button.classX').length, 0);
equal(panel.find('button.class1, button.class2').length, 3);
});
test("Psuedo:not", function() {
equal(panel.find('button:not(.class1)').length, 9);
equal(panel.find('button:not(buttongroup button)').length, 3);
equal(panel.find('button:not(toolbar button)').length, 9);
equal(panel.find('button:not(toolbar buttongroup button)').length, 9);
equal(panel.find('button:not(panel button)').length, 0);
equal(panel.find('button:not(.class1)').length, 9);
equal(panel.find('button:not(.class3, .class4)').length, 10);
});
test("Psuedo:odd/even/first/last", function() {
var matches;
matches = panel.find('button:first');
equal(matches.length, 4);
ok(matches[0].name() == 'button1');
ok(matches[3].name() == 'button10');
matches = panel.find('button:last');
equal(matches.length, 3);
ok(matches[0].name() == 'button6');
ok(matches[1].name() == 'button9');
matches = panel.find('button:odd');
equal(matches.length, 4);
ok(matches[0].name() == 'button2');
ok(matches[1].name() == 'button5');
matches = panel.find('button:even');
equal(matches.length, 8);
ok(matches[0].name() == 'button1');
ok(matches[1].name() == 'button3');
});
test("Psuedo:disabled", function() {
equal(panel.find('button:disabled').length, 2);
});
test("Attribute value", function() {
equal(panel.find('button[name]').length, 12);
equal(panel.find('button[name=button1]').length, 1);
equal(panel.find('button[name^=button1]').length, 4);
equal(panel.find('button[name$=1]').length, 2);
equal(panel.find('button[name*=utt]').length, 12);
equal(panel.find('button[name!=button1]').length, 11);
});
test("Direct descendant", function() {
equal(panel.find('> button').length, 3);
equal(panel.find('toolbar > buttongroup').length, 1);
equal(panel.find('toolbar > button').length, 0);
});
test("Parents", function() {
equal(panel.find("#button10")[0].parents("toolbar,buttongroup").length, 2);
equal(panel.find("#button10")[0].parents("panel").length, 1);
});
</script>
</head>
<body>
<h1 id="qunit-header">ui.Selector Test Suite</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>
<div id="view" style="position: absolute; right: 0; top: 0"></div>
</body>
</html>