The default for .clone() is to not clone any events. Fixes #8123.
[jquery.git] / test / unit / queue.js
1 module("queue", { teardown: moduleTeardown });
2
3 test("queue() with other types",function() {
4         expect(9);
5         var counter = 0;
6
7         var $div = jQuery({});
8
9         $div
10                 .queue('foo',function(){
11                         equals( ++counter, 1, "Dequeuing" );
12                         jQuery.dequeue(this,'foo');
13                 })
14                 .queue('foo',function(){
15                         equals( ++counter, 2, "Dequeuing" );
16                         jQuery(this).dequeue('foo');
17                 })
18                 .queue('foo',function(){
19                         equals( ++counter, 3, "Dequeuing" );
20                 })
21                 .queue('foo',function(){
22                         equals( ++counter, 4, "Dequeuing" );
23                 });
24
25         equals( $div.queue('foo').length, 4, "Testing queue length" );
26
27         $div.dequeue('foo');
28
29         equals( counter, 3, "Testing previous call to dequeue" );
30         equals( $div.queue('foo').length, 1, "Testing queue length" );
31
32         $div.dequeue('foo');
33
34         equals( counter, 4, "Testing previous call to dequeue" );
35         equals( $div.queue('foo').length, 0, "Testing queue length" );
36 });
37
38 test("queue(name) passes in the next item in the queue as a parameter", function() {
39         expect(2);
40
41         var div = jQuery({});
42         var counter = 0;
43
44         div.queue("foo", function(next) {
45                 equals(++counter, 1, "Dequeueing");
46                 next();
47         }).queue("foo", function(next) {
48                 equals(++counter, 2, "Next was called");
49                 next();
50         }).queue("bar", function() {
51                 equals(++counter, 3, "Other queues are not triggered by next()")
52         });
53
54         div.dequeue("foo");
55 });
56
57 test("queue(name) passes in the next item in the queue as a parameter", function() {
58         expect(2);
59
60         var div = jQuery({});
61         var counter = 0;
62
63         div.queue("foo", function(next) {
64                 equals(++counter, 1, "Dequeueing");
65                 next();
66         }).queue("foo", function(next) {
67                 equals(++counter, 2, "Next was called");
68                 next();
69         }).queue("bar", function() {
70                 equals(++counter, 3, "Other queues are not triggered by next()")
71         });
72
73         div.dequeue("foo");
74 });
75
76 test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
77         expect(2);
78         stop();
79
80         var div = jQuery({});
81         var counter = 0;
82
83         div.queue(function(next) {
84                 equals(++counter, 1, "Dequeueing");
85                 var self = this;
86                 setTimeout(function() { next() }, 500);
87         }).queue(function(next) {
88                 equals(++counter, 2, "Next was called");
89                 next();
90                 start();
91         }).queue("bar", function() {
92                 equals(++counter, 3, "Other queues are not triggered by next()")
93         });
94
95 });
96
97 test("delay()", function() {
98         expect(2);
99         stop();
100
101         var foo = jQuery({}), run = 0;
102
103         foo.delay(100).queue(function(){
104                 run = 1;
105                 ok( true, "The function was dequeued." );
106                 start();
107         });
108
109         equals( run, 0, "The delay delayed the next function from running." );
110 });
111
112 test("clearQueue(name) clears the queue", function() {
113         expect(1);
114
115         var div = jQuery({});
116         var counter = 0;
117
118         div.queue("foo", function(next) {
119                 counter++;
120                 jQuery(this).clearQueue("foo");
121                 next();
122         }).queue("foo", function(next) {
123                 counter++;
124         });
125
126         div.dequeue("foo");
127
128         equals(counter, 1, "the queue was cleared");
129 });
130
131 test("clearQueue() clears the fx queue", function() {
132         expect(1);
133
134         var div = jQuery({});
135         var counter = 0;
136
137         div.queue(function(next) {
138                 counter++;
139                 var self = this;
140                 setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
141         }).queue(function(next) {
142                 counter++;
143         });
144
145         equals(counter, 1, "the queue was cleared");
146
147         div.removeData();
148 });