1 | /*
|
---|
2 | * sortable_events.js
|
---|
3 | */
|
---|
4 | (function($) {
|
---|
5 |
|
---|
6 | module("sortable: events");
|
---|
7 |
|
---|
8 | test("start", function() {
|
---|
9 |
|
---|
10 | var hash;
|
---|
11 | $("#sortable")
|
---|
12 | .sortable({ start: function(e, ui) { hash = ui; } })
|
---|
13 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
---|
14 |
|
---|
15 | ok(hash, 'start event triggered');
|
---|
16 | ok(hash.helper, 'UI hash includes: helper');
|
---|
17 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
18 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
19 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
20 | ok(hash.item, 'UI hash includes: item');
|
---|
21 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
22 |
|
---|
23 |
|
---|
24 | });
|
---|
25 |
|
---|
26 | test("sort", function() {
|
---|
27 |
|
---|
28 | var hash;
|
---|
29 | $("#sortable")
|
---|
30 | .sortable({ sort: function(e, ui) { hash = ui; } })
|
---|
31 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 });
|
---|
32 |
|
---|
33 | ok(hash, 'sort event triggered');
|
---|
34 | ok(hash.helper, 'UI hash includes: helper');
|
---|
35 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
36 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
37 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
38 | ok(hash.item, 'UI hash includes: item');
|
---|
39 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
40 |
|
---|
41 | });
|
---|
42 |
|
---|
43 | test("change", function() {
|
---|
44 |
|
---|
45 | var hash;
|
---|
46 | $("#sortable")
|
---|
47 | .sortable({ change: function(e, ui) { hash = ui; } })
|
---|
48 | .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
|
---|
49 |
|
---|
50 | ok(!hash, '1px drag, change event should not be triggered');
|
---|
51 |
|
---|
52 | $("#sortable")
|
---|
53 | .sortable({ change: function(e, ui) { hash = ui; } })
|
---|
54 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
---|
55 |
|
---|
56 | ok(hash, 'change event triggered');
|
---|
57 | ok(hash.helper, 'UI hash includes: helper');
|
---|
58 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
59 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
60 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
61 | ok(hash.item, 'UI hash includes: item');
|
---|
62 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
63 |
|
---|
64 | });
|
---|
65 |
|
---|
66 | test("beforeStop", function() {
|
---|
67 |
|
---|
68 | var hash;
|
---|
69 | $("#sortable")
|
---|
70 | .sortable({ beforeStop: function(e, ui) { hash = ui; } })
|
---|
71 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
---|
72 |
|
---|
73 | ok(hash, 'beforeStop event triggered');
|
---|
74 | ok(hash.helper, 'UI hash includes: helper');
|
---|
75 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
76 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
77 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
78 | ok(hash.item, 'UI hash includes: item');
|
---|
79 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
80 |
|
---|
81 | });
|
---|
82 |
|
---|
83 | test("stop", function() {
|
---|
84 |
|
---|
85 | var hash;
|
---|
86 | $("#sortable")
|
---|
87 | .sortable({ stop: function(e, ui) { hash = ui; } })
|
---|
88 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
---|
89 |
|
---|
90 | ok(hash, 'stop event triggered');
|
---|
91 | ok(!hash.helper, 'UI should not include: helper');
|
---|
92 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
93 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
94 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
95 | ok(hash.item, 'UI hash includes: item');
|
---|
96 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
97 |
|
---|
98 | });
|
---|
99 |
|
---|
100 | test("update", function() {
|
---|
101 |
|
---|
102 | var hash;
|
---|
103 | $("#sortable")
|
---|
104 | .sortable({ update: function(e, ui) { hash = ui; } })
|
---|
105 | .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 });
|
---|
106 |
|
---|
107 | ok(!hash, '1px drag, update event should not be triggered');
|
---|
108 |
|
---|
109 | $("#sortable")
|
---|
110 | .sortable({ update: function(e, ui) { hash = ui; } })
|
---|
111 | .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 });
|
---|
112 |
|
---|
113 | ok(hash, 'update event triggered');
|
---|
114 | ok(!hash.helper, 'UI hash should not include: helper');
|
---|
115 | ok(hash.placeholder, 'UI hash includes: placeholder');
|
---|
116 | ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position');
|
---|
117 | ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset');
|
---|
118 | ok(hash.item, 'UI hash includes: item');
|
---|
119 | ok(!hash.sender, 'UI hash does not include: sender');
|
---|
120 |
|
---|
121 | });
|
---|
122 |
|
---|
123 | test("receive", function() {
|
---|
124 | ok(false, "missing test - untested code is broken code.");
|
---|
125 | });
|
---|
126 |
|
---|
127 | test("remove", function() {
|
---|
128 | ok(false, "missing test - untested code is broken code.");
|
---|
129 | });
|
---|
130 |
|
---|
131 | test("over", function() {
|
---|
132 | ok(false, "missing test - untested code is broken code.");
|
---|
133 | });
|
---|
134 |
|
---|
135 | test("out", function() {
|
---|
136 | ok(false, "missing test - untested code is broken code.");
|
---|
137 | });
|
---|
138 |
|
---|
139 | test("activate", function() {
|
---|
140 | ok(false, "missing test - untested code is broken code.");
|
---|
141 | });
|
---|
142 |
|
---|
143 | test("deactivate", function() {
|
---|
144 | ok(false, "missing test - untested code is broken code.");
|
---|
145 | });
|
---|
146 |
|
---|
147 | })(jQuery);
|
---|