change: function() {
ok(false, 'create() has triggered change()');
}
- })
+ });
});
test("change", function() {
$('<div></div>').resizable().resizable("foo").remove();
ok(true, 'arbitrary method called after init');
- el = $('<div></div>').resizable()
+ el = $('<div></div>').resizable();
var foo = el.resizable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
$("<div></div>").selectable().selectable("foo").remove();
ok(true, 'arbitrary method called after init');
- el = $("<div></div>").selectable()
+ el = $("<div></div>").selectable();
var foo = el.selectable("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
test("enable", function() {
expect(3);
- var fired = false;
+ var expected, actual,
+ fired = false;
el = $("#selectable1");
el.selectable({
equal(fired, true, "start fired");
el.selectable("destroy");
- var expected = $('<div></div>').selectable(),
- actual = expected.selectable('enable');
+ expected = $('<div></div>').selectable();
+ actual = expected.selectable('enable');
equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
expect(3);
- var fired = false;
+ var expected, actual,
+ fired = false;
el = $("#selectable1");
el.selectable({
equal(fired, false, "start fired");
el.selectable("destroy");
- var expected = $('<div></div>').selectable(),
- actual = expected.selectable('disable');
+ expected = $('<div></div>').selectable();
+ actual = expected.selectable('disable');
equal(actual, expected, 'disable is chainable');
});
test("autoRefresh", function() {
expect(3);
el = $("#selectable1");
- var actual, sel = $("*", el), selected = function() { actual += 1 };
+ var actual, sel = $("*", el), selected = function() { actual += 1; };
actual = 0;
el = $("#selectable1").selectable({ autoRefresh: false, selected: selected });
test("filter", function() {
expect(2);
el = $("#selectable1");
- var actual, sel = $("*", el), selected = function() { actual += 1 };
+ var actual, sel = $("*", el), selected = function() { actual += 1; };
actual = 0;
el = $("#selectable1").selectable({ filter: '.special', selected: selected });
drag(1000, 1000);
- ok(sel.length != 1, "this test assumes more than 1 selectee");
+ ok(sel.length !== 1, "this test assumes more than 1 selectee");
equal(actual, 1);
el.selectable("destroy");
});
$('<div></div>').slider().remove();
ok(true, '.slider() called on disconnected DOMElement');
- var el = $('<div></div>').slider();
- var foo = el.slider("option", "foo");
+ var el = $('<div></div>').slider(),
+ foo = el.slider("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
});
test("enable", function() {
- var expected = $('<div></div>').slider(),
+ var el,
+ expected = $('<div></div>').slider(),
actual = expected.slider('enable');
equal(actual, expected, 'enable is chainable');
- var el = $('<div></div>').slider({ disabled: true });
+ el = $('<div></div>').slider({ disabled: true });
ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class before enable method call');
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call');
el.slider('enable');
});
test("disable", function() {
- var expected = $('<div></div>').slider(),
+ var el,
+ expected = $('<div></div>').slider(),
actual = expected.slider('disable');
equal(actual, expected, 'disable is chainable');
- var el = $('<div></div>').slider({ disabled: false });
+ el = $('<div></div>').slider({ disabled: false });
ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class before disabled method call');
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call');
el.slider('disable');
};
el.slider(options);
- ok(el.slider("option", "value") == options.value, "value option is not contained by max");
- ok(el.slider("value") == options.max, "value method is contained by max");
+ ok(el.slider("option", "value") === options.value, "value option is not contained by max");
+ ok(el.slider("value") === options.max, "value method is contained by max");
el.slider('destroy');
});
};
el.slider(options);
- ok(el.slider("option", "value") == options.value, "value option is not contained by min");
- ok(el.slider("value") == options.min, "value method is contained by min");
+ ok(el.slider("option", "value") === options.value, "value option is not contained by min");
+ ok(el.slider("value") === options.min, "value method is contained by min");
el.slider('destroy');
});
value: -1
};
- var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
+ percentVal = (options.value - options.min) / (options.max - options.min) * 100;
el.slider(options).slider("option", "orientation", "vertical");
ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
module("sortable: events");
test("start", function() {
-
+
var hash;
$("#sortable")
.sortable({ start: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
-
- ok(hash, 'start event triggered');
+
+ ok(hash, 'start event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("sort", function() {
-
+
var hash;
$("#sortable")
.sortable({ sort: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
-
- ok(hash, 'sort event triggered');
+
+ ok(hash, 'sort event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("change", function() {
-
+
var hash;
$("#sortable")
.sortable({ change: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
-
+
ok(!hash, '1px drag, change event should not be triggered');
-
+
$("#sortable")
.sortable({ change: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'change event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'change event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("beforeStop", function() {
-
+
var hash;
$("#sortable")
.sortable({ beforeStop: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'beforeStop event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'beforeStop event triggered');
ok(hash.helper, 'UI hash includes: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("stop", function() {
-
+
var hash;
$("#sortable")
.sortable({ stop: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'stop event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'stop event triggered');
ok(!hash.helper, 'UI should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("update", function() {
-
+
var hash;
$("#sortable")
.sortable({ update: function(e, ui) { hash = ui; } })
.find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
-
+
ok(!hash, '1px drag, update event should not be triggered');
-
+
$("#sortable")
.sortable({ update: function(e, ui) { hash = ui; } })
- .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
-
- ok(hash, 'update event triggered');
+ .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
+
+ ok(hash, 'update event triggered');
ok(!hash.helper, 'UI hash should not include: helper');
ok(hash.placeholder, 'UI hash includes: placeholder');
ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
ok(hash.item, 'UI hash includes: item');
ok(!hash.sender, 'UI hash does not include: sender');
-
+
});
test("receive", function() {
var el, offsetBefore, offsetAfter, dragged;
-var drag = function(handle, dx, dy) {
+function drag(handle, dx, dy) {
offsetBefore = $(handle).offset();
$(handle).simulate("drag", {
dx: dx || 0,
offsetAfter = $(handle).offset();
}
-var sort = function(handle, dx, dy, index, msg) {
+function sort(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
equal($(handle).parent().children().index(handle), index, msg);
}
var el, offsetBefore, offsetAfter, dragged;
-var drag = function(handle, dx, dy) {
+function drag(handle, dx, dy) {
offsetBefore = $(handle).offset();
$(handle).simulate("drag", {
dx: dx || 0,
offsetAfter = $(handle).offset();
}
-var sort = function(handle, dx, dy, index, msg) {
+function sort(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
equal($(handle).parent().children().index(handle), index, msg);
}