source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/tests/unit/sortable/sortable_events.js@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1/*
2 * sortable_events.js
3 */
4(function($) {
5
6module("sortable: events");
7
8test("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
26test("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
43test("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
66test("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
83test("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
100test("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
123test("receive", function() {
124 ok(false, "missing test - untested code is broken code.");
125});
126
127test("remove", function() {
128 ok(false, "missing test - untested code is broken code.");
129});
130
131test("over", function() {
132 ok(false, "missing test - untested code is broken code.");
133});
134
135test("out", function() {
136 ok(false, "missing test - untested code is broken code.");
137});
138
139test("activate", function() {
140 ok(false, "missing test - untested code is broken code.");
141});
142
143test("deactivate", function() {
144 ok(false, "missing test - untested code is broken code.");
145});
146
147})(jQuery);
Note: See TracBrowser for help on using the repository browser.