2009-02-02 14:36:08 +00:00
|
|
|
/*
|
|
|
|
* selectable_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("selectable: methods");
|
|
|
|
|
2009-02-04 04:53:09 +00:00
|
|
|
test("init", function() {
|
|
|
|
expect(6);
|
|
|
|
|
|
|
|
$("<div></div>").appendTo('body').selectable().remove();
|
|
|
|
ok(true, '.selectable() called on element');
|
|
|
|
|
|
|
|
$([]).selectable().remove();
|
|
|
|
ok(true, '.selectable() called on empty collection');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().remove();
|
|
|
|
ok(true, '.selectable() called on disconnected DOMElement');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().selectable("foo").remove();
|
|
|
|
ok(true, 'arbitrary method called after init');
|
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
el = $("<div></div>").selectable();
|
2012-10-23 14:36:42 +00:00
|
|
|
el.selectable("option", "foo");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.remove();
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$("<div></div>").selectable().selectable("option", "foo", "bar").remove();
|
2009-02-04 04:53:09 +00:00
|
|
|
ok(true, 'arbitrary option setter after init');
|
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
|
|
|
$("<div></div>").appendTo('body').selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on element');
|
|
|
|
|
|
|
|
$([]).selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on empty collection');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().selectable("destroy").remove();
|
|
|
|
ok(true, '.selectable("destroy") called on disconnected DOMElement');
|
|
|
|
|
|
|
|
$("<div></div>").selectable().selectable("destroy").selectable("foo").remove();
|
|
|
|
ok(true, 'arbitrary method called after destroy');
|
|
|
|
|
2009-04-15 02:33:28 +00:00
|
|
|
var expected = $('<div></div>').selectable(),
|
|
|
|
actual = expected.selectable('destroy');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'destroy is chainable');
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(3);
|
2012-04-19 02:46:39 +00:00
|
|
|
var expected, actual,
|
|
|
|
fired = false;
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
el = $("#selectable1");
|
|
|
|
el.selectable({
|
|
|
|
disabled: true,
|
|
|
|
start: function() { fired = true; }
|
|
|
|
});
|
|
|
|
el.simulate("drag", 20, 20);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, false, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("enable");
|
|
|
|
el.simulate("drag", 20, 20);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, true, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("destroy");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
expected = $('<div></div>').selectable();
|
|
|
|
actual = expected.selectable('enable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'enable is chainable');
|
2009-02-04 04:53:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2009-04-15 02:33:28 +00:00
|
|
|
expect(3);
|
2012-04-19 02:46:39 +00:00
|
|
|
var expected, actual,
|
|
|
|
fired = false;
|
2009-02-04 04:53:09 +00:00
|
|
|
|
|
|
|
el = $("#selectable1");
|
|
|
|
el.selectable({
|
|
|
|
disabled: false,
|
|
|
|
start: function() { fired = true; }
|
|
|
|
});
|
|
|
|
el.simulate("drag", 20, 20);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, true, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("disable");
|
|
|
|
fired = false;
|
|
|
|
el.simulate("drag", 20, 20);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(fired, false, "start fired");
|
2009-02-04 04:53:09 +00:00
|
|
|
el.selectable("destroy");
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
expected = $('<div></div>').selectable();
|
|
|
|
actual = expected.selectable('disable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'disable is chainable');
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|