mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
tests: cleanup and consistency with defaults tests
This commit is contained in:
parent
7d946ec774
commit
e47820f6ea
116
tests/dialog.js
116
tests/dialog.js
@ -115,48 +115,48 @@ module("dialog");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#dialog1").dialog().remove();
|
$("<div></div>").appendTo('body').dialog().remove();
|
||||||
ok(true, '.dialog() called on element');
|
ok(true, '.dialog() called on element');
|
||||||
|
|
||||||
$([]).dialog().remove();
|
$([]).dialog().remove();
|
||||||
ok(true, '.dialog() called on empty collection');
|
ok(true, '.dialog() called on empty collection');
|
||||||
|
|
||||||
$('<div/>').dialog().remove();
|
$('<div></div>').dialog().remove();
|
||||||
ok(true, '.dialog() called on disconnected DOMElement');
|
ok(true, '.dialog() called on disconnected DOMElement');
|
||||||
|
|
||||||
$('<div/>').dialog().dialog("foo").remove();
|
$('<div></div>').dialog().dialog("foo").remove();
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
var foo = el.data("foo.dialog");
|
var foo = el.data("foo.dialog");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$('<div/>').dialog().data("foo.dialog", "bar").remove();
|
$('<div></div>').dialog().data("foo.dialog", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#dialog1").dialog().dialog("destroy").remove();
|
$("<div></div>").appendTo('body').dialog().dialog("destroy").remove();
|
||||||
ok(true, '.dialog("destroy") called on element');
|
ok(true, '.dialog("destroy") called on element');
|
||||||
|
|
||||||
$([]).dialog().dialog("destroy").remove();
|
$([]).dialog().dialog("destroy").remove();
|
||||||
ok(true, '.dialog("destroy") called on empty collection');
|
ok(true, '.dialog("destroy") called on empty collection');
|
||||||
|
|
||||||
$('<div/>').dialog().dialog("destroy").remove();
|
$('<div></div>').dialog().dialog("destroy").remove();
|
||||||
ok(true, '.dialog("destroy") called on disconnected DOMElement');
|
ok(true, '.dialog("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$('<div/>').dialog().dialog("destroy").dialog("foo").remove();
|
$('<div></div>').dialog().dialog("destroy").dialog("foo").remove();
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
var foo = el.dialog("destroy").data("foo.dialog");
|
var foo = el.dialog("destroy").data("foo.dialog");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$('<div/>').dialog().dialog("destroy").data("foo.dialog", "bar").remove();
|
$('<div></div>').dialog().dialog("destroy").data("foo.dialog", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ test("element types", function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
$.each(defaults, function(key, val) {
|
$.each(defaults, function(key, val) {
|
||||||
var actual = el.data(key + ".dialog"), expected = val;
|
var actual = el.data(key + ".dialog"), expected = val;
|
||||||
same(actual, expected, key);
|
same(actual, expected, key);
|
||||||
@ -199,12 +199,12 @@ test("title id", function() {
|
|||||||
// reset the uuid so we know what values to expect
|
// reset the uuid so we know what values to expect
|
||||||
$.ui.dialog.uuid = 0;
|
$.ui.dialog.uuid = 0;
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
titleId = dlg().find('.ui-dialog-title').attr('id');
|
titleId = dlg().find('.ui-dialog-title').attr('id');
|
||||||
equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
|
equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
titleId = dlg().find('.ui-dialog-title').attr('id');
|
titleId = dlg().find('.ui-dialog-title').attr('id');
|
||||||
equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
|
equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -220,11 +220,11 @@ module("dialog: Options");
|
|||||||
test("autoOpen", function() {
|
test("autoOpen", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ autoOpen: false });
|
el = $('<div></div>').dialog({ autoOpen: false });
|
||||||
isNotOpen('.dialog({ autoOpen: false })');
|
isNotOpen('.dialog({ autoOpen: false })');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ autoOpen: true });
|
el = $('<div></div>').dialog({ autoOpen: true });
|
||||||
isOpen('.dialog({ autoOpen: true })');
|
isOpen('.dialog({ autoOpen: true })');
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
@ -270,7 +270,7 @@ test("buttons", function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
el = $('<div/>').dialog({ buttons: buttons });
|
el = $('<div></div>').dialog({ buttons: buttons });
|
||||||
var btn = $("button", dlg());
|
var btn = $("button", dlg());
|
||||||
equals(btn.length, 2, "number of buttons");
|
equals(btn.length, 2, "number of buttons");
|
||||||
|
|
||||||
@ -311,15 +311,15 @@ test("buttons", function() {
|
|||||||
test("dialogClass", function() {
|
test("dialogClass", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
|
equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ dialogClass: "foo" });
|
el = $('<div></div>').dialog({ dialogClass: "foo" });
|
||||||
equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
|
equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ dialogClass: "foo bar" });
|
el = $('<div></div>').dialog({ dialogClass: "foo bar" });
|
||||||
equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
|
equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
|
||||||
equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
|
equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -328,13 +328,13 @@ test("dialogClass", function() {
|
|||||||
test("draggable", function() {
|
test("draggable", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ draggable: false });
|
el = $('<div></div>').dialog({ draggable: false });
|
||||||
shouldnotmove();
|
shouldnotmove();
|
||||||
el.data('draggable.dialog', true);
|
el.data('draggable.dialog', true);
|
||||||
shouldmove();
|
shouldmove();
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ draggable: true });
|
el = $('<div></div>').dialog({ draggable: true });
|
||||||
shouldmove();
|
shouldmove();
|
||||||
el.data('draggable.dialog', false);
|
el.data('draggable.dialog', false);
|
||||||
shouldnotmove();
|
shouldnotmove();
|
||||||
@ -344,15 +344,15 @@ test("draggable", function() {
|
|||||||
test("height", function() {
|
test("height", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
equals(dlg().height(), defaults.height, "default height");
|
equals(dlg().height(), defaults.height, "default height");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ height: 437 });
|
el = $('<div></div>').dialog({ height: 437 });
|
||||||
equals(dlg().height(), 437, "explicit height");
|
equals(dlg().height(), 437, "explicit height");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
el.data('height.dialog', 438);
|
el.data('height.dialog', 438);
|
||||||
equals(dlg().height(), 438, "explicit height set after init");
|
equals(dlg().height(), 438, "explicit height set after init");
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -361,17 +361,17 @@ test("height", function() {
|
|||||||
test("maxHeight", function() {
|
test("maxHeight", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxHeight: 400 });
|
el = $('<div></div>').dialog({ maxHeight: 400 });
|
||||||
drag('.ui-resizable-s', 1000, 1000);
|
drag('.ui-resizable-s', 1000, 1000);
|
||||||
equals(heightAfter, 400, "maxHeight");
|
equals(heightAfter, 400, "maxHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxHeight: 400 });
|
el = $('<div></div>').dialog({ maxHeight: 400 });
|
||||||
drag('.ui-resizable-n', -1000, -1000);
|
drag('.ui-resizable-n', -1000, -1000);
|
||||||
equals(heightAfter, 400, "maxHeight");
|
equals(heightAfter, 400, "maxHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600);
|
el = $('<div></div>').dialog({ maxHeight: 400 }).data('maxHeight.dialog', 600);
|
||||||
drag('.ui-resizable-n', -1000, -1000);
|
drag('.ui-resizable-n', -1000, -1000);
|
||||||
equals(heightAfter, 600, "maxHeight");
|
equals(heightAfter, 600, "maxHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -380,17 +380,17 @@ test("maxHeight", function() {
|
|||||||
test("maxWidth", function() {
|
test("maxWidth", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxWidth: 400 });
|
el = $('<div></div>').dialog({ maxWidth: 400 });
|
||||||
drag('.ui-resizable-e', 1000, 1000);
|
drag('.ui-resizable-e', 1000, 1000);
|
||||||
equals(widthAfter, 400, "maxWidth");
|
equals(widthAfter, 400, "maxWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxWidth: 400 });
|
el = $('<div></div>').dialog({ maxWidth: 400 });
|
||||||
drag('.ui-resizable-w', -1000, -1000);
|
drag('.ui-resizable-w', -1000, -1000);
|
||||||
equals(widthAfter, 400, "maxWidth");
|
equals(widthAfter, 400, "maxWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600);
|
el = $('<div></div>').dialog({ maxWidth: 400 }).data('maxWidth.dialog', 600);
|
||||||
drag('.ui-resizable-w', -1000, -1000);
|
drag('.ui-resizable-w', -1000, -1000);
|
||||||
equals(widthAfter, 600, "maxWidth");
|
equals(widthAfter, 600, "maxWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -399,17 +399,17 @@ test("maxWidth", function() {
|
|||||||
test("minHeight", function() {
|
test("minHeight", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minHeight: 10 });
|
el = $('<div></div>').dialog({ minHeight: 10 });
|
||||||
drag('.ui-resizable-s', -1000, -1000);
|
drag('.ui-resizable-s', -1000, -1000);
|
||||||
equals(heightAfter, 10, "minHeight");
|
equals(heightAfter, 10, "minHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minHeight: 10 });
|
el = $('<div></div>').dialog({ minHeight: 10 });
|
||||||
drag('.ui-resizable-n', 1000, 1000);
|
drag('.ui-resizable-n', 1000, 1000);
|
||||||
equals(heightAfter, 10, "minHeight");
|
equals(heightAfter, 10, "minHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30);
|
el = $('<div></div>').dialog({ minHeight: 10 }).data('minHeight.dialog', 30);
|
||||||
drag('.ui-resizable-n', 1000, 1000);
|
drag('.ui-resizable-n', 1000, 1000);
|
||||||
equals(heightAfter, 30, "minHeight");
|
equals(heightAfter, 30, "minHeight");
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -418,17 +418,17 @@ test("minHeight", function() {
|
|||||||
test("minWidth", function() {
|
test("minWidth", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minWidth: 10 });
|
el = $('<div></div>').dialog({ minWidth: 10 });
|
||||||
drag('.ui-resizable-e', -1000, -1000);
|
drag('.ui-resizable-e', -1000, -1000);
|
||||||
equals(widthAfter, 10, "minWidth");
|
equals(widthAfter, 10, "minWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minWidth: 10 });
|
el = $('<div></div>').dialog({ minWidth: 10 });
|
||||||
drag('.ui-resizable-w', 1000, 1000);
|
drag('.ui-resizable-w', 1000, 1000);
|
||||||
equals(widthAfter, 10, "minWidth");
|
equals(widthAfter, 10, "minWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30);
|
el = $('<div></div>').dialog({ minWidth: 30 }).data('minWidth.dialog', 30);
|
||||||
drag('.ui-resizable-w', 1000, 1000);
|
drag('.ui-resizable-w', 1000, 1000);
|
||||||
equals(widthAfter, 30, "minWidth");
|
equals(widthAfter, 30, "minWidth");
|
||||||
el.remove();
|
el.remove();
|
||||||
@ -449,13 +449,13 @@ test("position", function() {
|
|||||||
test("resizable", function() {
|
test("resizable", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
shouldresize("[default]");
|
shouldresize("[default]");
|
||||||
el.data('resizable.dialog', false);
|
el.data('resizable.dialog', false);
|
||||||
shouldnotresize('disabled after init');
|
shouldnotresize('disabled after init');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ resizable: false });
|
el = $('<div></div>').dialog({ resizable: false });
|
||||||
shouldnotresize("disabled in init options");
|
shouldnotresize("disabled in init options");
|
||||||
el.data('resizable.dialog', true);
|
el.data('resizable.dialog', true);
|
||||||
shouldresize('enabled after init');
|
shouldresize('enabled after init');
|
||||||
@ -473,7 +473,7 @@ test("title", function() {
|
|||||||
return dlg().find(".ui-dialog-title").html();
|
return dlg().find(".ui-dialog-title").html();
|
||||||
}
|
}
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
equals(titleText(), " ", "[default]");
|
equals(titleText(), " ", "[default]");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ test("title", function() {
|
|||||||
equals(titleText(), "foo", "title in element attribute");
|
equals(titleText(), "foo", "title in element attribute");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({ title: 'foo' });
|
el = $('<div></div>').dialog({ title: 'foo' });
|
||||||
equals(titleText(), "foo", "title in init options");
|
equals(titleText(), "foo", "title in init options");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ test("title", function() {
|
|||||||
equals(titleText(), "bar", "title in init options should override title in element attribute");
|
equals(titleText(), "bar", "title in init options should override title in element attribute");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog().data('title.dialog', 'foo');
|
el = $('<div></div>').dialog().data('title.dialog', 'foo');
|
||||||
equals(titleText(), 'foo', 'title after init');
|
equals(titleText(), 'foo', 'title after init');
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
@ -497,11 +497,11 @@ test("title", function() {
|
|||||||
test("width", function() {
|
test("width", function() {
|
||||||
expect(3);
|
expect(3);
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
equals(dlg().width(), defaults.width, "default width");
|
equals(dlg().width(), defaults.width, "default width");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({width: 437 });
|
el = $('<div></div>').dialog({width: 437 });
|
||||||
equals(dlg().width(), 437, "explicit width");
|
equals(dlg().width(), 437, "explicit width");
|
||||||
el.data('width.dialog', 438);
|
el.data('width.dialog', 438);
|
||||||
equals(dlg().width(), 438, 'explicit width after init');
|
equals(dlg().width(), 438, 'explicit width after init');
|
||||||
@ -513,13 +513,13 @@ module("dialog: Methods");
|
|||||||
test("isOpen", function() {
|
test("isOpen", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
el = $('<div/>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
equals(el.dialog('isOpen'), true, "dialog is open after init");
|
equals(el.dialog('isOpen'), true, "dialog is open after init");
|
||||||
el.dialog('close');
|
el.dialog('close');
|
||||||
equals(el.dialog('isOpen'), false, "dialog is closed");
|
equals(el.dialog('isOpen'), false, "dialog is closed");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({autoOpen: false});
|
el = $('<div></div>').dialog({autoOpen: false});
|
||||||
equals(el.dialog('isOpen'), false, "dialog is closed after init");
|
equals(el.dialog('isOpen'), false, "dialog is closed after init");
|
||||||
el.dialog('open');
|
el.dialog('open');
|
||||||
equals(el.dialog('isOpen'), true, "dialog is open");
|
equals(el.dialog('isOpen'), true, "dialog is open");
|
||||||
@ -531,7 +531,7 @@ module("dialog: Callbacks");
|
|||||||
test("open", function() {
|
test("open", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
open: function(ev, ui) {
|
open: function(ev, ui) {
|
||||||
ok(true, 'autoOpen: true fires open callback');
|
ok(true, 'autoOpen: true fires open callback');
|
||||||
@ -540,7 +540,7 @@ test("open", function() {
|
|||||||
});
|
});
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
open: function(ev, ui) {
|
open: function(ev, ui) {
|
||||||
@ -551,7 +551,7 @@ test("open", function() {
|
|||||||
el.dialog("open");
|
el.dialog("open");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog({
|
el = $('<div></div>').dialog({
|
||||||
autoOpen: false
|
autoOpen: false
|
||||||
});
|
});
|
||||||
el.bind('dialogopen', function(ev, ui) {
|
el.bind('dialogopen', function(ev, ui) {
|
||||||
@ -565,7 +565,7 @@ test("open", function() {
|
|||||||
test("dragStart", function() {
|
test("dragStart", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
dragStart: function(ev, ui) {
|
dragStart: function(ev, ui) {
|
||||||
ok(true, 'dragging fires dragStart callback');
|
ok(true, 'dragging fires dragStart callback');
|
||||||
@ -580,7 +580,7 @@ test("dragStart", function() {
|
|||||||
test("drag", function() {
|
test("drag", function() {
|
||||||
var fired = false;
|
var fired = false;
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
drag: function(ev, ui) {
|
drag: function(ev, ui) {
|
||||||
fired = true;
|
fired = true;
|
||||||
@ -596,7 +596,7 @@ test("drag", function() {
|
|||||||
test("dragStop", function() {
|
test("dragStop", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
dragStop: function(ev, ui) {
|
dragStop: function(ev, ui) {
|
||||||
ok(true, 'dragging fires dragStop callback');
|
ok(true, 'dragging fires dragStop callback');
|
||||||
@ -611,7 +611,7 @@ test("dragStop", function() {
|
|||||||
test("resizeStart", function() {
|
test("resizeStart", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
resizeStart: function(ev, ui) {
|
resizeStart: function(ev, ui) {
|
||||||
ok(true, 'resizing fires resizeStart callback');
|
ok(true, 'resizing fires resizeStart callback');
|
||||||
@ -626,7 +626,7 @@ test("resizeStart", function() {
|
|||||||
test("resize", function() {
|
test("resize", function() {
|
||||||
var fired = false;
|
var fired = false;
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
resize: function(ev, ui) {
|
resize: function(ev, ui) {
|
||||||
fired = true;
|
fired = true;
|
||||||
@ -642,7 +642,7 @@ test("resize", function() {
|
|||||||
test("resizeStop", function() {
|
test("resizeStop", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
el = $("<div/>");
|
el = $("<div></div>");
|
||||||
el.dialog({
|
el.dialog({
|
||||||
resizeStop: function(ev, ui) {
|
resizeStop: function(ev, ui) {
|
||||||
ok(true, 'resizing fires resizeStop callback');
|
ok(true, 'resizing fires resizeStop callback');
|
||||||
@ -657,7 +657,7 @@ test("resizeStop", function() {
|
|||||||
test("close", function() {
|
test("close", function() {
|
||||||
expect(4);
|
expect(4);
|
||||||
|
|
||||||
el = $('<div/>').dialog({
|
el = $('<div></div>').dialog({
|
||||||
close: function(ev, ui) {
|
close: function(ev, ui) {
|
||||||
ok(true, '.dialog("close") fires close callback');
|
ok(true, '.dialog("close") fires close callback');
|
||||||
equals(this, el[0], "context of callback");
|
equals(this, el[0], "context of callback");
|
||||||
@ -666,7 +666,7 @@ test("close", function() {
|
|||||||
el.dialog("close");
|
el.dialog("close");
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog().bind('dialogclose', function(ev, ui) {
|
el = $('<div></div>').dialog().bind('dialogclose', function(ev, ui) {
|
||||||
ok(true, '.dialog("close") firse dialogclose event');
|
ok(true, '.dialog("close") firse dialogclose event');
|
||||||
equals(this, el[0], 'context of event');
|
equals(this, el[0], 'context of event');
|
||||||
});
|
});
|
||||||
@ -677,7 +677,7 @@ test("close", function() {
|
|||||||
test("beforeclose", function() {
|
test("beforeclose", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
el = $('<div/>').dialog({
|
el = $('<div></div>').dialog({
|
||||||
beforeclose: function(ev, ui) {
|
beforeclose: function(ev, ui) {
|
||||||
ok(true, '.dialog("close") fires beforeclose callback');
|
ok(true, '.dialog("close") fires beforeclose callback');
|
||||||
equals(this, el[0], "context of callback");
|
equals(this, el[0], "context of callback");
|
||||||
@ -688,7 +688,7 @@ test("beforeclose", function() {
|
|||||||
isOpen('beforeclose callback should prevent dialog from closing');
|
isOpen('beforeclose callback should prevent dialog from closing');
|
||||||
el.remove();
|
el.remove();
|
||||||
|
|
||||||
el = $('<div/>').dialog().bind('dialogbeforeclose', function(ev, ui) {
|
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
|
||||||
ok(true, '.dialog("close") triggers dialogbeforeclose event');
|
ok(true, '.dialog("close") triggers dialogbeforeclose event');
|
||||||
equals(this, el[0], "context of event");
|
equals(this, el[0], "context of event");
|
||||||
return false;
|
return false;
|
||||||
|
@ -5,6 +5,37 @@
|
|||||||
//
|
//
|
||||||
// Draggable Test Helper Functions
|
// Draggable Test Helper Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
appendTo: "parent",
|
||||||
|
axis: false,
|
||||||
|
cancel: ":input",
|
||||||
|
connectToSortable: false,
|
||||||
|
containment: false,
|
||||||
|
cursor: "default",
|
||||||
|
cursorAt: null,
|
||||||
|
delay: 0,
|
||||||
|
disabled: false,
|
||||||
|
distance: 1,
|
||||||
|
grid: false,
|
||||||
|
handle: false,
|
||||||
|
helper: "original",
|
||||||
|
iframeFix: false,
|
||||||
|
opacity: 1.0,
|
||||||
|
refreshPositions: false,
|
||||||
|
revert: false,
|
||||||
|
revertDuration: 500,
|
||||||
|
scroll: false,
|
||||||
|
scrollSensitivity: 20,
|
||||||
|
scrollSpeed: 20,
|
||||||
|
scope: "default",
|
||||||
|
snap: false,
|
||||||
|
snapMode: "both",
|
||||||
|
snapTolerance: 20,
|
||||||
|
stack: false,
|
||||||
|
zIndex: null
|
||||||
|
};
|
||||||
|
|
||||||
var el, offsetBefore, offsetAfter, dragged;
|
var el, offsetBefore, offsetAfter, dragged;
|
||||||
|
|
||||||
var drag = function(handle, dx, dy) {
|
var drag = function(handle, dx, dy) {
|
||||||
@ -45,44 +76,44 @@ module("draggable");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
el = $("#draggable1").draggable();
|
$("<div></div>").appendTo('body').draggable().remove();
|
||||||
ok(true, '.draggable() called on element');
|
ok(true, '.draggable() called on element');
|
||||||
|
|
||||||
$([]).draggable();
|
$([]).draggable();
|
||||||
ok(true, '.draggable() called on empty collection');
|
ok(true, '.draggable() called on empty collection');
|
||||||
|
|
||||||
$("<div/>").draggable();
|
$("<div></div>").draggable();
|
||||||
ok(true, '.draggable() called on disconnected DOMElement');
|
ok(true, '.draggable() called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").draggable().draggable("foo");
|
$("<div></div>").draggable().draggable("foo");
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
$("<div/>").draggable().data("foo.draggable");
|
$("<div></div>").draggable().data("foo.draggable");
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$("<div/>").draggable().data("foo.draggable", "bar");
|
$("<div></div>").draggable().data("foo.draggable", "bar");
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#draggable1").draggable().draggable("destroy");
|
$("<div></div>").appendTo('body').draggable().draggable("destroy").remove();
|
||||||
ok(true, '.draggable("destroy") called on element');
|
ok(true, '.draggable("destroy") called on element');
|
||||||
|
|
||||||
$([]).draggable().draggable("destroy");
|
$([]).draggable().draggable("destroy");
|
||||||
ok(true, '.draggable("destroy") called on empty collection');
|
ok(true, '.draggable("destroy") called on empty collection');
|
||||||
|
|
||||||
$("<div/>").draggable().draggable("destroy");
|
$("<div></div>").draggable().draggable("destroy");
|
||||||
ok(true, '.draggable("destroy") called on disconnected DOMElement');
|
ok(true, '.draggable("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").draggable().draggable("destroy").draggable("foo");
|
$("<div></div>").draggable().draggable("destroy").draggable("foo");
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
$("<div/>").draggable().draggable("destroy").data("foo.draggable");
|
$("<div></div>").draggable().draggable("destroy").data("foo.draggable");
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$("<div/>").draggable().draggable("destroy").data("foo.draggable", "bar");
|
$("<div></div>").draggable().draggable("destroy").data("foo.draggable", "bar");
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -138,42 +169,12 @@ test("element types", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
|
el = $('<div></div>').draggable();
|
||||||
var expected = {
|
$.each(defaults, function(key, val) {
|
||||||
appendTo: "parent",
|
var actual = el.data(key + ".draggable"), expected = val;
|
||||||
axis: false,
|
same(actual, expected, key);
|
||||||
cancel: ":input",
|
});
|
||||||
connectToSortable: false,
|
el.remove();
|
||||||
containment: false,
|
|
||||||
cursor: "default",
|
|
||||||
cursorAt: null,
|
|
||||||
delay: 0,
|
|
||||||
disabled: false,
|
|
||||||
distance: 1,
|
|
||||||
grid: false,
|
|
||||||
handle: false,
|
|
||||||
helper: "original",
|
|
||||||
iframeFix: false,
|
|
||||||
opacity: 1.0,
|
|
||||||
refreshPositions: false,
|
|
||||||
revert: false,
|
|
||||||
revertDuration: 500,
|
|
||||||
scroll: false,
|
|
||||||
scrollSensitivity: 20,
|
|
||||||
scrollSpeed: 20,
|
|
||||||
scope: "default",
|
|
||||||
snap: false,
|
|
||||||
snapMode: "both",
|
|
||||||
snapTolerance: 20,
|
|
||||||
stack: false,
|
|
||||||
zIndex: null
|
|
||||||
};
|
|
||||||
|
|
||||||
el = $("#draggable1").draggable();
|
|
||||||
|
|
||||||
for (var optionName in expected)
|
|
||||||
equals(el.data(optionName + ".draggable"), expected[optionName], optionName);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("No options, relative", function() {
|
test("No options, relative", function() {
|
||||||
|
@ -33,44 +33,44 @@ module("droppable");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
el = $("#droppable1").droppable();
|
$("<div></div>").appendTo('body').droppable().remove();
|
||||||
ok(true, '.droppable() called on element');
|
ok(true, '.droppable() called on element');
|
||||||
|
|
||||||
$([]).droppable();
|
$([]).droppable();
|
||||||
ok(true, '.droppable() called on empty collection');
|
ok(true, '.droppable() called on empty collection');
|
||||||
|
|
||||||
$("<div/>").droppable();
|
$("<div></div>").droppable();
|
||||||
ok(true, '.droppable() called on disconnected DOMElement');
|
ok(true, '.droppable() called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").droppable().droppable("foo");
|
$("<div></div>").droppable().droppable("foo");
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
$("<div/>").droppable().data("foo.droppable");
|
$("<div></div>").droppable().data("foo.droppable");
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$("<div/>").droppable().data("foo.droppable", "bar");
|
$("<div></div>").droppable().data("foo.droppable", "bar");
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#droppable1").droppable().droppable("destroy");
|
$("<div></div>").appendTo('body').droppable().droppable("destroy").remove();
|
||||||
ok(true, '.droppable("destroy") called on element');
|
ok(true, '.droppable("destroy") called on element');
|
||||||
|
|
||||||
$([]).droppable().droppable("destroy");
|
$([]).droppable().droppable("destroy");
|
||||||
ok(true, '.droppable("destroy") called on empty collection');
|
ok(true, '.droppable("destroy") called on empty collection');
|
||||||
|
|
||||||
$("<div/>").droppable().droppable("destroy");
|
$("<div></div>").droppable().droppable("destroy");
|
||||||
ok(true, '.droppable("destroy") called on disconnected DOMElement');
|
ok(true, '.droppable("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").droppable().droppable("destroy").droppable("foo");
|
$("<div></div>").droppable().droppable("destroy").droppable("foo");
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
$("<div/>").droppable().droppable("destroy").data("foo.droppable");
|
$("<div></div>").droppable().droppable("destroy").data("foo.droppable");
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$("<div/>").droppable().droppable("destroy").data("foo.droppable", "bar");
|
$("<div></div>").droppable().droppable("destroy").data("foo.droppable", "bar");
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,14 +2,28 @@
|
|||||||
* progressbar unit tests
|
* progressbar unit tests
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
//
|
||||||
|
// Progressbar Test Helper Functions
|
||||||
|
//
|
||||||
|
|
||||||
// Spinner Tests
|
var defaults = {
|
||||||
|
disabled: false,
|
||||||
|
duration: 1000,
|
||||||
|
increment: 1,
|
||||||
|
interval: 1000,
|
||||||
|
range: true,
|
||||||
|
width: 300
|
||||||
|
};
|
||||||
|
|
||||||
|
var el;
|
||||||
|
|
||||||
|
// Progressbar Tests
|
||||||
module("progressbar");
|
module("progressbar");
|
||||||
|
|
||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(1);
|
expect(1);
|
||||||
|
|
||||||
el = $("#progressbar").progressbar();
|
$("<div></div>").appendTo('body').progressbar().remove();
|
||||||
ok(true, '.progressbar() called on element');
|
ok(true, '.progressbar() called on element');
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -17,21 +31,18 @@ test("init", function() {
|
|||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(1);
|
expect(1);
|
||||||
|
|
||||||
$("#progressbar").progressbar().progressbar("destroy");
|
$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove();
|
||||||
ok(true, '.progressbar("destroy") called on element');
|
ok(true, '.progressbar("destroy") called on element');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
expect(5);
|
el = $('<div></div>').progressbar();
|
||||||
el = $("#progressbar").progressbar();
|
$.each(defaults, function(key, val) {
|
||||||
|
var actual = el.data(key + ".progressbar"), expected = val;
|
||||||
equals(el.data("width.progressbar"), 300, "width");
|
same(actual, expected, key);
|
||||||
equals(el.data("duration.progressbar"), 1000, "duration");
|
});
|
||||||
equals(el.data("interval.progressbar"), 1000, "interval");
|
el.remove();
|
||||||
equals(el.data("increment.progressbar"), 1, "increment");
|
|
||||||
equals(el.data("range.progressbar"), true, "range");
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("set defaults on init", function() {
|
test("set defaults on init", function() {
|
||||||
|
@ -6,20 +6,6 @@
|
|||||||
// Resizable Test Helper Functions
|
// Resizable Test Helper Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
var drag = function(el, dx, dy, complete) {
|
|
||||||
|
|
||||||
// speed = sync -> Drag syncrhonously.
|
|
||||||
// speed = fast|slow -> Drag asyncrhonously - animated.
|
|
||||||
|
|
||||||
//this mouseover is to work around a limitation in resizable
|
|
||||||
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
|
||||||
$(el).simulate("mouseover");
|
|
||||||
|
|
||||||
return $(el).simulate("drag", {
|
|
||||||
dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
animate: false,
|
animate: false,
|
||||||
animateDuration: 'slow',
|
animateDuration: 'slow',
|
||||||
@ -48,54 +34,68 @@ var defaults = {
|
|||||||
transparent: false
|
transparent: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var drag = function(el, dx, dy, complete) {
|
||||||
|
|
||||||
|
// speed = sync -> Drag syncrhonously.
|
||||||
|
// speed = fast|slow -> Drag asyncrhonously - animated.
|
||||||
|
|
||||||
|
//this mouseover is to work around a limitation in resizable
|
||||||
|
//TODO: fix resizable so handle doesn't require mouseover in order to be used
|
||||||
|
$(el).simulate("mouseover");
|
||||||
|
|
||||||
|
return $(el).simulate("drag", {
|
||||||
|
dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Resizable Tests
|
// Resizable Tests
|
||||||
module("resizable");
|
module("resizable");
|
||||||
|
|
||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#resizable1").resizable().remove();
|
$("<div></div>").appendTo('body').resizable().remove();
|
||||||
ok(true, '.resizable() called on element');
|
ok(true, '.resizable() called on element');
|
||||||
|
|
||||||
$([]).resizable().remove();
|
$([]).resizable().remove();
|
||||||
ok(true, '.resizable() called on empty collection');
|
ok(true, '.resizable() called on empty collection');
|
||||||
|
|
||||||
$('<div/>').resizable().remove();
|
$('<div></div>').resizable().remove();
|
||||||
ok(true, '.resizable() called on disconnected DOMElement');
|
ok(true, '.resizable() called on disconnected DOMElement');
|
||||||
|
|
||||||
$('<div/>').resizable().resizable("foo").remove();
|
$('<div></div>').resizable().resizable("foo").remove();
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
el = $('<div/>').resizable()
|
el = $('<div></div>').resizable()
|
||||||
var foo = el.data("foo.resizable");
|
var foo = el.data("foo.resizable");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$('<div/>').resizable().data("foo.resizable", "bar").remove();
|
$('<div></div>').resizable().data("foo.resizable", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#dialog1").resizable().resizable("destroy").remove();
|
$("<div></div>").appendTo('body').resizable().resizable("destroy").remove();
|
||||||
ok(true, '.resizable("destroy") called on element');
|
ok(true, '.resizable("destroy") called on element');
|
||||||
|
|
||||||
$([]).resizable().resizable("destroy").remove();
|
$([]).resizable().resizable("destroy").remove();
|
||||||
ok(true, '.resizable("destroy") called on empty collection');
|
ok(true, '.resizable("destroy") called on empty collection');
|
||||||
|
|
||||||
$('<div/>').resizable().resizable("destroy").remove();
|
$('<div></div>').resizable().resizable("destroy").remove();
|
||||||
ok(true, '.resizable("destroy") called on disconnected DOMElement');
|
ok(true, '.resizable("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$('<div/>').resizable().resizable("destroy").resizable("foo").remove();
|
$('<div></div>').resizable().resizable("destroy").resizable("foo").remove();
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
el = $('<div/>').resizable();
|
el = $('<div></div>').resizable();
|
||||||
var foo = el.resizable("destroy").data("foo.resizable");
|
var foo = el.resizable("destroy").data("foo.resizable");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$('<div/>').resizable().resizable("destroy").data("foo.resizable", "bar").remove();
|
$('<div></div>').resizable().resizable("destroy").data("foo.resizable", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ test("element types", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
el = $('<div/>').resizable();
|
el = $('<div></div>').resizable();
|
||||||
$.each(defaults, function(key, val) {
|
$.each(defaults, function(key, val) {
|
||||||
var actual = el.data(key + ".resizable"), expected = val;
|
var actual = el.data(key + ".resizable"), expected = val;
|
||||||
same(actual, expected, key);
|
same(actual, expected, key);
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
//
|
//
|
||||||
// Selectable Test Helper Functions
|
// Selectable Test Helper Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
autoRefresh: true,
|
||||||
|
disabled: false,
|
||||||
|
filter: '*'
|
||||||
|
};
|
||||||
|
|
||||||
var el;
|
var el;
|
||||||
|
|
||||||
var drag = function(dx, dy) {
|
var drag = function(dx, dy) {
|
||||||
@ -27,57 +34,53 @@ module("selectable");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#selectable1").selectable().remove();
|
$("<div></div>").appendTo('body').selectable().remove();
|
||||||
ok(true, '.selectable() called on element');
|
ok(true, '.selectable() called on element');
|
||||||
|
|
||||||
$([]).selectable().remove();
|
$([]).selectable().remove();
|
||||||
ok(true, '.selectable() called on empty collection');
|
ok(true, '.selectable() called on empty collection');
|
||||||
|
|
||||||
$("<div/>").selectable().remove();
|
$("<div></div>").selectable().remove();
|
||||||
ok(true, '.selectable() called on disconnected DOMElement');
|
ok(true, '.selectable() called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").selectable().selectable("foo").remove();
|
$("<div></div>").selectable().selectable("foo").remove();
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
el = $("<div/>").selectable()
|
el = $("<div></div>").selectable()
|
||||||
var foo = el.data("foo.selectable");
|
var foo = el.data("foo.selectable");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$("<div/>").selectable().data("foo.selectable", "bar").remove();
|
$("<div></div>").selectable().data("foo.selectable", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#selectable1").selectable().selectable("destroy").remove();
|
$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
|
||||||
ok(true, '.selectable("destroy") called on element');
|
ok(true, '.selectable("destroy") called on element');
|
||||||
|
|
||||||
$([]).selectable().selectable("destroy").remove();
|
$([]).selectable().selectable("destroy").remove();
|
||||||
ok(true, '.selectable("destroy") called on empty collection');
|
ok(true, '.selectable("destroy") called on empty collection');
|
||||||
|
|
||||||
$("<div/>").selectable().selectable("destroy").remove();
|
$("<div></div>").selectable().selectable("destroy").remove();
|
||||||
ok(true, '.selectable("destroy") called on disconnected DOMElement');
|
ok(true, '.selectable("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").selectable().selectable("destroy").selectable("foo").remove();
|
$("<div></div>").selectable().selectable("destroy").selectable("foo").remove();
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
el = $("<div/>").selectable();
|
el = $("<div></div>").selectable();
|
||||||
var foo = el.selectable("destroy").data("foo.selectable");
|
var foo = el.selectable("destroy").data("foo.selectable");
|
||||||
el.remove();
|
el.remove();
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$("<div/>").selectable().selectable("destroy").data("foo.selectable", "bar").remove();
|
$("<div></div>").selectable().selectable("destroy").data("foo.selectable", "bar").remove();
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
el = $('#selectable1').selectable();
|
el = $('<div></div>').selectable();
|
||||||
var defaults = {
|
|
||||||
autoRefresh: true,
|
|
||||||
filter: '*'
|
|
||||||
};
|
|
||||||
$.each(defaults, function(key, val) {
|
$.each(defaults, function(key, val) {
|
||||||
var actual = el.data(key + ".selectable"), expected = val;
|
var actual = el.data(key + ".selectable"), expected = val;
|
||||||
same(actual, expected, key);
|
same(actual, expected, key);
|
||||||
|
@ -2,6 +2,23 @@
|
|||||||
* slider unit tests
|
* slider unit tests
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
//
|
||||||
|
// Selectable Test Helper Functions
|
||||||
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
animate: false,
|
||||||
|
axis: "???",
|
||||||
|
handle: ".ui-slider-handle",
|
||||||
|
handles: "???",
|
||||||
|
disabled: false,
|
||||||
|
max: 100,
|
||||||
|
min: 0,
|
||||||
|
range: false,
|
||||||
|
startValue: "???",
|
||||||
|
stepping: "???",
|
||||||
|
steps: 0
|
||||||
|
};
|
||||||
|
|
||||||
var keyCodes = {
|
var keyCodes = {
|
||||||
leftArrow: 37,
|
leftArrow: 37,
|
||||||
@ -32,7 +49,67 @@ function assertChange(stepping, start, result, action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module("slider: single handle")
|
// Slider Tests
|
||||||
|
module("slider");
|
||||||
|
|
||||||
|
test("init", function() {
|
||||||
|
expect(6);
|
||||||
|
|
||||||
|
$("<div></div>").appendTo('body').slider().remove();
|
||||||
|
ok(true, '.slider() called on element');
|
||||||
|
|
||||||
|
$([]).slider().remove();
|
||||||
|
ok(true, '.slider() called on empty collection');
|
||||||
|
|
||||||
|
$('<div></div>').slider().remove();
|
||||||
|
ok(true, '.slider() called on disconnected DOMElement');
|
||||||
|
|
||||||
|
$('<div></div>').slider().slider("foo").remove();
|
||||||
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
|
el = $('<div></div>').slider();
|
||||||
|
var foo = el.data("foo.slider");
|
||||||
|
el.remove();
|
||||||
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
|
$('<div></div>').slider().data("foo.slider", "bar").remove();
|
||||||
|
ok(true, 'arbitrary option setter after init');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("destroy", function() {
|
||||||
|
expect(6);
|
||||||
|
|
||||||
|
$("<div></div>").appendTo('body').slider().slider("destroy").remove();
|
||||||
|
ok(true, '.slider("destroy") called on element');
|
||||||
|
|
||||||
|
$([]).slider().slider("destroy").remove();
|
||||||
|
ok(true, '.slider("destroy") called on empty collection');
|
||||||
|
|
||||||
|
$('<div></div>').slider().slider("destroy").remove();
|
||||||
|
ok(true, '.slider("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
|
$('<div></div>').slider().slider("destroy").slider("foo").remove();
|
||||||
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
|
el = $('<div></div>').slider();
|
||||||
|
var foo = el.slider("destroy").data("foo.slider");
|
||||||
|
el.remove();
|
||||||
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
|
$('<div></div>').slider().slider("destroy").data("foo.slider", "bar").remove();
|
||||||
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("defaults", function() {
|
||||||
|
el = $('<div></div>').slider();
|
||||||
|
$.each(defaults, function(key, val) {
|
||||||
|
var actual = el.data(key + ".slider"), expected = val;
|
||||||
|
same(actual, expected, key);
|
||||||
|
});
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
module("slider: single handle");
|
||||||
|
|
||||||
test("change one step via keydown", assertChange(1, undefined, 1, function() {
|
test("change one step via keydown", assertChange(1, undefined, 1, function() {
|
||||||
this.find("a").rightArrow();
|
this.find("a").rightArrow();
|
||||||
|
@ -5,6 +5,23 @@
|
|||||||
//
|
//
|
||||||
// Sortable Test Helper Functions
|
// Sortable Test Helper Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
appendTo: "parent",
|
||||||
|
cancel: ":input",
|
||||||
|
delay: 0,
|
||||||
|
disabled: false,
|
||||||
|
distance: 1,
|
||||||
|
dropOnEmpty: true,
|
||||||
|
helper: "original",
|
||||||
|
items: "> *",
|
||||||
|
scroll: true,
|
||||||
|
scrollSensitivity: 20,
|
||||||
|
scrollSpeed: 20,
|
||||||
|
tolerance: "guess",
|
||||||
|
zIndex: 1000
|
||||||
|
};
|
||||||
|
|
||||||
var el, offsetBefore, offsetAfter, dragged;
|
var el, offsetBefore, offsetAfter, dragged;
|
||||||
|
|
||||||
var drag = function(handle, dx, dy) {
|
var drag = function(handle, dx, dy) {
|
||||||
@ -31,44 +48,44 @@ module("sortable");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
el = $("#sortable").sortable();
|
$("<div></div>").appendTo('body').sortable().remove();
|
||||||
ok(true, '.sortable() called on element');
|
ok(true, '.sortable() called on element');
|
||||||
|
|
||||||
$([]).sortable();
|
$([]).sortable();
|
||||||
ok(true, '.sortable() called on empty collection');
|
ok(true, '.sortable() called on empty collection');
|
||||||
|
|
||||||
$("<div/>").sortable();
|
$("<div></div>").sortable();
|
||||||
ok(true, '.sortable() called on disconnected DOMElement');
|
ok(true, '.sortable() called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").sortable().sortable("foo");
|
$("<div></div>").sortable().sortable("foo");
|
||||||
ok(true, 'arbitrary method called after init');
|
ok(true, 'arbitrary method called after init');
|
||||||
|
|
||||||
$("<div/>").sortable().data("foo.sortable");
|
$("<div></div>").sortable().data("foo.sortable");
|
||||||
ok(true, 'arbitrary option getter after init');
|
ok(true, 'arbitrary option getter after init');
|
||||||
|
|
||||||
$("<div/>").sortable().data("foo.sortable", "bar");
|
$("<div></div>").sortable().data("foo.sortable", "bar");
|
||||||
ok(true, 'arbitrary option setter after init');
|
ok(true, 'arbitrary option setter after init');
|
||||||
});
|
});
|
||||||
|
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(6);
|
expect(6);
|
||||||
|
|
||||||
$("#sortable").sortable().sortable("destroy");
|
$("<div></div>").appendTo('body').sortable().sortable("destroy").remove();
|
||||||
ok(true, '.sortable("destroy") called on element');
|
ok(true, '.sortable("destroy") called on element');
|
||||||
|
|
||||||
$([]).sortable().sortable("destroy");
|
$([]).sortable().sortable("destroy");
|
||||||
ok(true, '.sortable("destroy") called on empty collection');
|
ok(true, '.sortable("destroy") called on empty collection');
|
||||||
|
|
||||||
$("<div/>").sortable().sortable("destroy");
|
$("<div></div>").sortable().sortable("destroy");
|
||||||
ok(true, '.sortable("destroy") called on disconnected DOMElement');
|
ok(true, '.sortable("destroy") called on disconnected DOMElement');
|
||||||
|
|
||||||
$("<div/>").sortable().sortable("destroy").sortable("foo");
|
$("<div></div>").sortable().sortable("destroy").sortable("foo");
|
||||||
ok(true, 'arbitrary method called after destroy');
|
ok(true, 'arbitrary method called after destroy');
|
||||||
|
|
||||||
$("<div/>").sortable().sortable("destroy").data("foo.sortable");
|
$("<div></div>").sortable().sortable("destroy").data("foo.sortable");
|
||||||
ok(true, 'arbitrary option getter after destroy');
|
ok(true, 'arbitrary option getter after destroy');
|
||||||
|
|
||||||
$("<div/>").sortable().sortable("destroy").data("foo.sortable", "bar");
|
$("<div></div>").sortable().sortable("destroy").data("foo.sortable", "bar");
|
||||||
ok(true, 'arbitrary option setter after destroy');
|
ok(true, 'arbitrary option setter after destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,22 +124,12 @@ test("disable", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
el = $("#sortable").sortable();
|
el = $('<div></div>').sortable();
|
||||||
|
$.each(defaults, function(key, val) {
|
||||||
equals(el.data("helper.sortable"), "original", "helper");
|
var actual = el.data(key + ".sortable"), expected = val;
|
||||||
equals(el.data("tolerance.sortable"), "guess", "tolerance");
|
same(actual, expected, key);
|
||||||
equals(el.data("distance.sortable"), 1, "distance");
|
});
|
||||||
equals(el.data("disabled.sortable"), false, "disabled");
|
el.remove();
|
||||||
equals(el.data("delay.sortable"), 0, "delay");
|
|
||||||
equals(el.data("scroll.sortable"), true, "scroll");
|
|
||||||
equals(el.data("scrollSensitivity.sortable"), 20, "scrollSensitivity");
|
|
||||||
equals(el.data("scrollSpeed.sortable"), 20, "scrollSpeed");
|
|
||||||
equals(el.data("cancel.sortable"), ":input", "cancel");
|
|
||||||
equals(el.data("items.sortable"), "> *", "items");
|
|
||||||
equals(el.data("zIndex.sortable"), 1000, "zIndex");
|
|
||||||
equals(el.data("dropOnEmpty.sortable"), true, "dropOnEmpty");
|
|
||||||
equals(el.data("appendTo.sortable"), "parent", "appendTo");
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("#3019: Stop fires too early", function() {
|
test("#3019: Stop fires too early", function() {
|
||||||
|
@ -2,6 +2,26 @@
|
|||||||
* spinner unit tests
|
* spinner unit tests
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
//
|
||||||
|
// Spinner Test Helper Functions
|
||||||
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
currency: false,
|
||||||
|
decimals: 0,
|
||||||
|
disabled: false,
|
||||||
|
format: "%",
|
||||||
|
group: "",
|
||||||
|
incremental: true,
|
||||||
|
items: null,
|
||||||
|
max: null,
|
||||||
|
min: null,
|
||||||
|
point: ".",
|
||||||
|
start: 0,
|
||||||
|
stepping: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
var el;
|
||||||
|
|
||||||
// Spinner Tests
|
// Spinner Tests
|
||||||
module("spinner");
|
module("spinner");
|
||||||
@ -9,7 +29,7 @@ module("spinner");
|
|||||||
test("init", function() {
|
test("init", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
$("#spin").spinner();
|
$("<div></div>").appendTo('body').spinner().remove();
|
||||||
ok(true, '.spinner() called on element');
|
ok(true, '.spinner() called on element');
|
||||||
|
|
||||||
$('<input id="spinner_dis">').spinner().remove();
|
$('<input id="spinner_dis">').spinner().remove();
|
||||||
@ -20,7 +40,7 @@ test("init", function() {
|
|||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
$("#spin").spinner().spinner("destroy");
|
$("<div></div>").appendTo('body').spinner().spinner("destroy").remove();
|
||||||
ok(true, '.spinner("destroy") called on element');
|
ok(true, '.spinner("destroy") called on element');
|
||||||
|
|
||||||
$('<input id="spinner_dis">').spinner().spinner("destroy").remove();
|
$('<input id="spinner_dis">').spinner().spinner("destroy").remove();
|
||||||
@ -28,6 +48,15 @@ test("destroy", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("defaults", function() {
|
||||||
|
el = $('<div></div>').spinner();
|
||||||
|
$.each(defaults, function(key, val) {
|
||||||
|
var actual = el.data(key + ".spinner"), expected = val;
|
||||||
|
same(actual, expected, key);
|
||||||
|
});
|
||||||
|
el.remove();
|
||||||
|
});
|
||||||
|
|
||||||
test("re-attach", function() {
|
test("re-attach", function() {
|
||||||
expect(2);
|
expect(2);
|
||||||
|
|
||||||
|
@ -2,6 +2,32 @@
|
|||||||
* tabs unit tests
|
* tabs unit tests
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
//
|
||||||
|
// Tabs Test Helper Functions
|
||||||
|
//
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
ajaxOptions: null,
|
||||||
|
cache: false,
|
||||||
|
cookie: null,
|
||||||
|
deselectable: false,
|
||||||
|
deselectableClass: 'ui-tabs-deselectable',
|
||||||
|
disabled: [],
|
||||||
|
disabledClass: 'ui-tabs-disabled',
|
||||||
|
event: 'click',
|
||||||
|
fx: null,
|
||||||
|
hideClass: 'ui-tabs-hide',
|
||||||
|
idPrefix: 'ui-tabs-',
|
||||||
|
loadingClass: 'ui-tabs-loading',
|
||||||
|
navClass: 'ui-tabs-nav',
|
||||||
|
panelClass: 'ui-tabs-panel',
|
||||||
|
panelTemplate: '<div></div>',
|
||||||
|
selectedClass: 'ui-tabs-selected',
|
||||||
|
spinner: 'Loading…',
|
||||||
|
tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>'
|
||||||
|
};
|
||||||
|
|
||||||
|
var el;
|
||||||
|
|
||||||
// need to wait a bit for the pseudo animation...
|
// need to wait a bit for the pseudo animation...
|
||||||
function defer(defered, ms) {
|
function defer(defered, ms) {
|
||||||
@ -35,35 +61,12 @@ module('tabs');
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("defaults", function() {
|
test("defaults", function() {
|
||||||
|
el = $('#tabs1').tabs();
|
||||||
var expected = {
|
$.each(defaults, function(key, val) {
|
||||||
deselectable: false,
|
var actual = el.data(key + ".tabs"), expected = val;
|
||||||
event: 'click',
|
same(actual, expected, key);
|
||||||
disabled: [],
|
});
|
||||||
cookie: null,
|
el.tabs("destroy");
|
||||||
spinner: 'Loading…',
|
|
||||||
cache: false,
|
|
||||||
idPrefix: 'ui-tabs-',
|
|
||||||
ajaxOptions: null,
|
|
||||||
fx: null,
|
|
||||||
tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
|
|
||||||
panelTemplate: '<div></div>',
|
|
||||||
navClass: 'ui-tabs-nav',
|
|
||||||
selectedClass: 'ui-tabs-selected',
|
|
||||||
deselectableClass: 'ui-tabs-deselectable',
|
|
||||||
disabledClass: 'ui-tabs-disabled',
|
|
||||||
panelClass: 'ui-tabs-panel',
|
|
||||||
hideClass: 'ui-tabs-hide',
|
|
||||||
loadingClass: 'ui-tabs-loading'
|
|
||||||
};
|
|
||||||
|
|
||||||
var el = $("#tabs1").tabs();
|
|
||||||
|
|
||||||
for (var optionName in expected) {
|
|
||||||
var actual = el.data(optionName + '.tabs'), expects = expected[optionName];
|
|
||||||
same(actual, expects, optionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('add', function() {
|
test('add', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user