1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* draggable_methods.js
*/
(function($) {
module("draggable: methods");
test("init", function() {
expect(5);
$("<div></div>").appendTo("body").draggable().remove();
ok(true, ".draggable() called on element");
$([]).draggable();
ok(true, ".draggable() called on empty collection");
$("<div></div>").draggable();
ok(true, ".draggable() called on disconnected DOMElement");
$("<div></div>").draggable().draggable("option", "foo");
ok(true, "arbitrary option getter after init");
$("<div></div>").draggable().draggable("option", "foo", "bar");
ok(true, "arbitrary option setter after init");
});
test("destroy", function() {
expect(4);
$("<div></div>").appendTo("body").draggable().draggable("destroy").remove();
ok(true, ".draggable('destroy') called on element");
$([]).draggable().draggable("destroy");
ok(true, ".draggable('destroy') called on empty collection");
$("<div></div>").draggable().draggable("destroy");
ok(true, ".draggable('destroy') called on disconnected DOMElement");
var expected = $("<div></div>").draggable(),
actual = expected.draggable("destroy");
equal(actual, expected, "destroy is chainable");
});
test("enable", function() {
expect(7);
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: true });
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
el.draggable("enable");
TestHelpers.draggable.shouldMove(el, ".draggable('enable')");
equal(el.draggable("option", "disabled"), false, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: true });
TestHelpers.draggable.shouldNotMove(el, ".draggable({ disabled: true })");
el.draggable("option", "disabled", false);
equal(el.draggable("option", "disabled"), false, "disabled option setter");
TestHelpers.draggable.shouldMove(el, ".draggable('option', 'disabled', false)");
expected = $("<div></div>").draggable(),
actual = expected.draggable("enable");
equal(actual, expected, "enable is chainable");
});
test("disable", function() {
expect(7);
var expected, actual, el;
el = $("#draggable2").draggable({ disabled: false });
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
el.draggable("disable");
TestHelpers.draggable.shouldNotMove(el, ".draggable('disable')");
equal(el.draggable("option", "disabled"), true, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: false });
TestHelpers.draggable.shouldMove(el, ".draggable({ disabled: false })");
el.draggable("option", "disabled", true);
equal(el.draggable("option", "disabled"), true, "disabled option setter");
TestHelpers.draggable.shouldNotMove(el, ".draggable('option', 'disabled', true)");
expected = $("<div></div>").draggable(),
actual = expected.draggable("disable");
equal(actual, expected, "disable is chainable");
});
})(jQuery);
|