Wordpress/tests/qunit/editor/tinymce/ui/Button.html

134 lines
3.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Button 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">
QUnit.config.autostart = false;
QUnit.config.reorder = false;
module("ui.Button", {
setup: function() {
document.getElementById('view').innerHTML = '';
},
teardown: function() {
//document.getElementById('view').innerHTML = '';
}
});
window.onload = function() {
QUnit.start();
};
function createButton(settings) {
return tinymce.ui.Factory.create(tinymce.extend({
type: 'button'
}, settings)).renderTo(document.getElementById('view'));
}
test("button text, size default", function() {
var button = createButton({text: 'X'});
nearlyEqualRects(rect(button), [0, 0, 34, 30], 4);
});
test("button text, size large", function() {
var button = createButton({text: 'X', size: 'large'});
nearlyEqualRects(rect(button), [0, 0, 41, 39], 4);
});
test("button text, size small", function() {
var button = createButton({text: 'X', size: 'small'});
nearlyEqualRects(rect(button), [0, 0, 19, 23], 4);
});
test("button text, width 100, height 100", function() {
var button = createButton({text: 'X', width: 100, height: 100});
deepEqual(rect(button), [0, 0, 100, 100]);
deepEqual(rect(button.getEl().firstChild), [1, 1, 98, 98]);
});
test("button icon, size default", function() {
var button = createButton({icon: 'test'});
nearlyEqualRects(rect(button), [0, 0, 40, 30], 4);
});
test("button icon, size small", function() {
var button = createButton({icon: 'test', size: 'small'});
nearlyEqualRects(rect(button), [0, 0, 28, 24], 4);
});
test("button icon, size large", function() {
var button = createButton({icon: 'test', size: 'large'});
nearlyEqualRects(rect(button), [0, 0, 44, 40], 4);
});
test("button icon, width 100, height 100", function() {
var button = createButton({icon: 'test', width: 100, height: 100});
deepEqual(rect(button), [0, 0, 100, 100]);
deepEqual(rect(button.getEl().firstChild), [1, 1, 98, 98]);
});
test("button text & icon, size default", function() {
var button = createButton({text: 'X', icon: 'test'});
nearlyEqualRects(rect(button), [0, 0, 52, 30], 4);
});
test("button text & icon, size large", function() {
var button = createButton({text: 'X', icon: 'test', size: 'large'});
nearlyEqualRects(rect(button), [0, 0, 59, 40], 4);
});
test("button text & icon, size small", function() {
var button = createButton({text: 'X', icon: 'test', size: 'small'});
nearlyEqualRects(rect(button), [0, 0, 38, 24], 4);
});
test("button text & icon, width 100, height 100", function() {
var button = createButton({text: 'X', icon: 'test', width: 100, height: 100});
deepEqual(rect(button), [0, 0, 100, 100]);
deepEqual(rect(button.getEl().firstChild), [1, 1, 98, 98]);
});
test("button click event", function() {
var button, clicks = {};
button = createButton({text: 'X', onclick: function() {clicks.a = 'a';}});
button.on('click', function() {clicks.b = 'b';});
button.on('click', function() {clicks.c = 'c';});
button.fire('click');
deepEqual(clicks, {a: 'a', b: 'b', c: 'c'});
});
</script>
</head>
<body>
<h1 id="qunit-header">Button 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>