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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
define( [
"jquery",
"./helper",
"ui/widgets/sortable"
], function( $, testHelper ) {
module( "sortable: methods" );
test( "init", function() {
expect( 5 );
$( "<div></div>" ).appendTo( "body" ).sortable().remove();
ok( true, ".sortable() called on element" );
$( [] ).sortable();
ok( true, ".sortable() called on empty collection" );
$( "<div></div>" ).sortable();
ok( true, ".sortable() called on disconnected DOMElement" );
$( "<div></div>" ).sortable().sortable( "option", "foo" );
ok( true, "arbitrary option getter after init" );
$( "<div></div>" ).sortable().sortable( "option", "foo", "bar" );
ok( true, "arbitrary option setter after init" );
} );
test( "destroy", function() {
expect( 4 );
$( "<div></div>" ).appendTo( "body" ).sortable().sortable( "destroy" ).remove();
ok( true, ".sortable('destroy') called on element" );
$( [] ).sortable().sortable( "destroy" );
ok( true, ".sortable('destroy') called on empty collection" );
$( "<div></div>" ).sortable().sortable( "destroy" );
ok( true, ".sortable('destroy') called on disconnected DOMElement" );
var expected = $( "<div></div>" ).sortable(),
actual = expected.sortable( "destroy" );
equal( actual, expected, "destroy is chainable" );
} );
test( "enable", function() {
expect( 5 );
var el, actual, expected;
el = $( "#sortable" ).sortable( { disabled: true } );
testHelper.sort( $( "li", el )[ 0 ], 0, 44, 0, ".sortable({ disabled: true })" );
el.sortable( "enable" );
equal( el.sortable( "option", "disabled" ), false, "disabled option getter" );
el.sortable( "destroy" );
el.sortable( { disabled: true } );
el.sortable( "option", "disabled", false );
equal( el.sortable( "option", "disabled" ), false, "disabled option setter" );
testHelper.sort( $( "li", el )[ 0 ], 0, 44, 2, ".sortable('option', 'disabled', false)" );
expected = $( "<div></div>" ).sortable(),
actual = expected.sortable( "enable" );
equal( actual, expected, "enable is chainable" );
} );
test( "disable", function( assert ) {
expect( 9 );
var chainable,
element = $( "#sortable" ).sortable( { disabled: false } );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
chainable = element.sortable( "disable" );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" );
element.sortable( "destroy" );
element.sortable( { disabled: false } );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
element.sortable( "option", "disabled", true );
equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
assert.lacksClasses( element.sortable( "widget" ), "ui-state-disabled" );
ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" );
testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
equal( chainable, element, "disable is chainable" );
} );
test( "refresh() should update the positions of initially empty lists (see #7498)", function() {
expect( 1 );
var changeCount = 0,
element = $( "#qunit-fixture" ).html( "<ul></ul>" ).find( "ul" );
element
.css( {
"float": "left",
width: "100px"
} )
.sortable( {
change: function() {
changeCount++;
}
} )
.append( "<li>a</li><li>a</li>" )
.find( "li" )
.css( {
"float": "left",
width: "50px",
height: "50px"
} );
element.sortable( "refresh" );
// Switch the order of the two li elements
element.find( "li" ).eq( 0 ).simulate( "drag", {
dx: 55,
moves: 15
} );
equal( changeCount, 1 );
} );
} );
|