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
95
96
97
98
99
100
101
102
103
104
|
define( [
"jquery",
"./draggable_test_helpers",
"ui/draggable"
], function( $, draggableTestHelpers ) {
var element;
module( "draggable: methods", {
setup: function() {
element = $("<div style='background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;'><span>Absolute</span></div>").appendTo("#qunit-fixture");
},
teardown: function() {
element.remove();
}
});
test( "init", function() {
expect( 5 );
element.draggable();
ok( true, ".draggable() called on element" );
$([]).draggable();
ok( true, ".draggable() called on empty collection" );
$("<div></div>").draggable();
ok( true, ".draggable() called on disconnected DOMElement" );
element.draggable( "option", "foo" );
ok( true, "arbitrary option getter after init" );
element.draggable( "option", "foo", "bar" );
ok( true, "arbitrary option setter after init" );
});
test( "destroy", function() {
expect( 4 );
element.draggable().draggable("destroy");
ok( true, ".draggable('destroy') called on element" );
$([]).draggable().draggable("destroy");
ok( true, ".draggable('destroy') called on empty collection" );
element.draggable().draggable("destroy");
ok( true, ".draggable('destroy') called on disconnected DOMElement" );
var expected = element.draggable(),
actual = expected.draggable("destroy");
equal( actual, expected, "destroy is chainable" );
});
test( "enable", function() {
expect( 11 );
element.draggable({ disabled: true });
draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" );
element.draggable("enable");
draggableTestHelpers.shouldMove( element, ".draggable('enable')" );
equal( element.draggable( "option", "disabled" ), false, "disabled option getter" );
element.draggable("destroy");
element.draggable({ disabled: true });
draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" );
element.draggable( "option", "disabled", false );
equal(element.draggable( "option", "disabled" ), false, "disabled option setter" );
draggableTestHelpers.shouldMove( element, ".draggable('option', 'disabled', false)" );
var expected = element.draggable(),
actual = expected.draggable("enable");
equal( actual, expected, "enable is chainable" );
});
test( "disable", function( assert ) {
expect( 14 );
element = $( "#draggable2" ).draggable({ disabled: false });
draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" );
element.draggable( "disable" );
draggableTestHelpers.shouldNotDrag( element, ".draggable('disable')" );
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
element.draggable( "destroy" );
element.draggable({ disabled: false });
draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" );
element.draggable( "option", "disabled", true );
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
draggableTestHelpers.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );
assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" );
ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
assert.hasClasses( element.draggable( "widget" ), "ui-draggable-disabled" );
var expected = element.draggable(),
actual = expected.draggable( "disable" );
equal( actual, expected, "disable is chainable" );
});
} );
|