0898014ebd
In 4.0.20 all tests were reworked. The 'testrunner' was removed and the PhantomJS Runner QUnit plugin was added making it possible to run the tests from cli. However it is still necessary to run the tests in all supported browsers to test the fixes for all browser quirks and normalization. Also all tests are loaded in one html file. See #27014 git-svn-id: https://develop.svn.wordpress.org/trunk@27679 602fd350-edb4-49c9-b593-d223f7449a82
105 lines
3.0 KiB
JavaScript
105 lines
3.0 KiB
JavaScript
(function() {
|
|
module("tinymce.ui.Button", {
|
|
setup: function() {
|
|
document.getElementById('view').innerHTML = '';
|
|
},
|
|
|
|
teardown: function() {
|
|
tinymce.dom.Event.clean(document.getElementById('view'));
|
|
}
|
|
});
|
|
|
|
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'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 34, 30], 4);
|
|
});
|
|
|
|
test("button text, size large", function() {
|
|
var button = createButton({text: 'X', size: 'large'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 41, 39], 4);
|
|
});
|
|
|
|
test("button text, size small", function() {
|
|
var button = createButton({text: 'X', size: 'small'});
|
|
|
|
Utils.nearlyEqualRects(Utils.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(Utils.rect(button), [0, 0, 100, 100]);
|
|
deepEqual(Utils.rect(button.getEl().firstChild), [1, 1, 98, 98]);
|
|
});
|
|
|
|
test("button icon, size default", function() {
|
|
var button = createButton({icon: 'test'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 40, 30], 4);
|
|
});
|
|
|
|
test("button icon, size small", function() {
|
|
var button = createButton({icon: 'test', size: 'small'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 28, 24], 4);
|
|
});
|
|
|
|
test("button icon, size large", function() {
|
|
var button = createButton({icon: 'test', size: 'large'});
|
|
|
|
Utils.nearlyEqualRects(Utils.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(Utils.rect(button), [0, 0, 100, 100]);
|
|
deepEqual(Utils.rect(button.getEl().firstChild), [1, 1, 98, 98]);
|
|
});
|
|
|
|
test("button text & icon, size default", function() {
|
|
var button = createButton({text: 'X', icon: 'test'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 52, 30], 4);
|
|
});
|
|
|
|
test("button text & icon, size large", function() {
|
|
var button = createButton({text: 'X', icon: 'test', size: 'large'});
|
|
|
|
Utils.nearlyEqualRects(Utils.rect(button), [0, 0, 59, 40], 4);
|
|
});
|
|
|
|
test("button text & icon, size small", function() {
|
|
var button = createButton({text: 'X', icon: 'test', size: 'small'});
|
|
|
|
Utils.nearlyEqualRects(Utils.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(Utils.rect(button), [0, 0, 100, 100]);
|
|
deepEqual(Utils.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'});
|
|
});
|
|
})();
|
|
|