Permalink
Browse files

updated tests and reverse to work with jQuery 1.9. Mostly replacing $…

….fn.live with $.fn.on
  • Loading branch information...
justinbmeyer committed Feb 6, 2013
1 parent 4d90e4c commit 692ed50a7b43fb2c6bfb9d89c5e0505ddcbd6595
@@ -30,28 +30,43 @@ test("default and pause with delegate", function(){
});
test("default and pause with live", function(){
test("default and pause with live or on", function(){
$("#qunit-test-area").html("<div id='foo_default_pause'>hello</div>")
var order = [];
var order = [],
defaultShow = function(){
order.push("default")
},
show = function(ev){
order.push('show')
ev.pause();
setTimeout(function(){
ev.resume();
setTimeout(function(){
start();
same(order,['show','default']);
if($.fn.live){
$("#foo_default_pause").die("show");
$("#foo_default_pause").die("default.show");
} else {
$(document.body).off("default.show");
$(document.body).off("show");
}
},30)
},50)
};
stop();
$("#foo_default_pause").live("default.show", function(){
order.push("default")
});
$("#foo_default_pause").live("show", function(ev){
order.push('show')
ev.pause();
setTimeout(function(){
ev.resume();
setTimeout(function(){
start();
same(order,['show','default'])
$("#foo_default_pause").die("show");
$("#foo_default_pause").die("default.show");
},30)
},50)
});
if( $.fn.live ){
$("#foo_default_pause").live("default.show", defaultShow);
$("#foo_default_pause").live("show", show);
} else {
$(document.body).on("default.show", "#foo_default_pause",defaultShow);
$(document.body).on("show", "#foo_default_pause",show);
}
$("#foo_default_pause").trigger("show")
@@ -62,26 +77,37 @@ test("default and pause with live", function(){
test("triggerAsync", function(){
$("#qunit-test-area").html("<div id='foo_default_pause'>hello</div>")
var order = [];
stop();
$("#foo_default_pause").live("default.show", function(){
order.push("default")
});
$("#foo_default_pause").live("show", function(ev){
order.push('show')
ev.pause();
setTimeout(function(){
ev.resume();
var order = [],
defaultShow = function(){
order.push("default")
},
show = function(ev){
order.push('show')
ev.pause();
setTimeout(function(){
start();
$("#foo_default_pause").die()
same(order,['show','default','async'])
},30)
},50)
});
ev.resume();
setTimeout(function(){
start();
if( $.fn.die ) {
$("#foo_default_pause").die();
} else {
$(document.body).off();
}
same(order,['show','default','async'])
},30)
},50)
};
stop();
if( $.fn.live ){
$("#foo_default_pause").live("default.show", defaultShow);
$("#foo_default_pause").live("show", show);
} else {
$(document.body).on("default.show", "#foo_default_pause",defaultShow);
$(document.body).on("show", "#foo_default_pause",show);
}
$("#foo_default_pause").triggerAsync("show", function(){
order.push("async")
@@ -94,19 +120,20 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called be
var order = [];
stop();
$("#foo_default_pause").live("default.show", function(){
$(document.body).on("default.show","#foo_default_pause", function(){
order.push("default")
});
$("#foo_default_pause").live("show", function(ev){
$(document.body).on("show", "#foo_default_pause", function(ev){
order.push('show');
ev.preventDefault();
ev.pause();
setTimeout(function(){
ev.resume();
setTimeout(function(){
start();
$("#foo_default_pause").die()
$(document.body).off("show");
$(document.body).off("default.show")
same(order,['show','prevented'])
},30)
},50)
@@ -125,11 +152,11 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
var order = [];
stop();
$("#foo_default_pause").live("default.show", function(){
$(document.body).on("default.show", "#foo_default_pause",function(){
order.push("default")
});
$("#foo_default_pause").live("show", function(ev){
$(document.body).on("show", "#foo_default_pause",function(ev){
order.push('show');
ev.pause();
@@ -138,7 +165,7 @@ test("triggerAsync with prevented callback when ev.preventDefault() is called af
ev.resume();
setTimeout(function(){
start();
$("#foo_default_pause").die()
$(document.body).off("show").off("default.show")
same(order,['show','prevented'])
},30)
},50)
@@ -158,16 +185,16 @@ test("triggerAsync within another triggerAsync", function(){
var order = [];
stop();
$("#foo_default_pause").live("default.show", function(){
$(document.body).on("default.show", "#foo_default_pause",function(){
order.push("show default")
});
$("#foo_default_pause").live("default.hide", function(){
$(document.body).on("default.hide", "#foo_default_pause", function(){
order.push("hide default")
});
$("#foo_default_pause").live("hide", function(){
$(document.body).on("hide", "#foo_default_pause",function(){
order.push("hide")
});
$("#foo_default_pause").live("show", function(ev){
$(document.body).on("show", "#foo_default_pause",function(ev){
order.push('show');
ev.pause();
$("#foo_default_pause").triggerAsync("hide",function(){
@@ -176,7 +203,7 @@ test("triggerAsync within another triggerAsync", function(){
setTimeout(function(){
start();
$("#foo_default_pause").die()
$(document.body).off()
same(order,['show','hide','hide default',"hide async","show default","show async"])
},30)
@@ -199,16 +226,16 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
var order = [];
stop();
$("#foo_default_pause").live("default.show", function(){
$(document.body).on("default.show", "#foo_default_pause",function(){
order.push("show default")
});
$("#foo_default_pause").live("default.hide", function(){
$(document.body).on("default.hide", "#foo_default_pause", function(){
order.push("hide default")
});
$("#foo_default_pause").live("hide", function(){
$(document.body).on("hide", "#foo_default_pause",function(){
order.push("hide")
});
$("#foo_default_pause").live("show", function(ev){
$(document.body).on("show", "#foo_default_pause", function(ev){
order.push('show');
ev.preventDefault();
ev.pause();
@@ -217,7 +244,7 @@ test("triggerAsync within another triggerAsync with prevented callback", functio
ev.resume();
setTimeout(function(){
start();
$("#foo_default_pause").die()
$(document.body).off()
same(order,['show','hide','hide default',"hide async","show prevented"])
},30)
@@ -64,7 +64,7 @@ test("triggering defaults", function(){
test("live on default events", function(){
test("on default events", function(){
$("#qunit-test-area").html(
@@ -76,16 +76,13 @@ test("live on default events", function(){
count3 = 0;
var jq = $();
jq.context = bw[0];
jq.selector = "#wrap1"
jq.live("default.touch", function(){
jq.selector = "#wrap1";
$("#qunit-test-area").on("default.touch","#wrap1", function(){
count1++;
});
//2nd selector
var jq2 = $();
jq2.context = bw[0];
jq2.selector = "#wrap2"
jq2.live("default.touching", function(){
$("#qunit-test-area").on("default.touching", "#wrap2",function(){
count2++;
});
@@ -113,17 +110,17 @@ test("default and live order", function(){
var order = [];
$("#qunit-test-area").html("<div id='foo'></div>")
$("#foo").live("default.show", function(){
$(document.body).on("default.show", "#foo",function(){
order.push("default")
});
$("#foo").live("show", function(){
$(document.body).on("show","#foo", function(){
order.push("show")
});
$("#foo").trigger("show")
same(order, ['show','default'],"show then default")
$("#foo").die()
$(document.body).off()
});
View
@@ -41,46 +41,46 @@ test("dragging an element", function(){
var drags = {}, drops ={};
$('#drag')
.live("dragdown", function(){
$("#qunit-test-area")
.on("dragdown", '#drag',function(){
drags.dragdown = true;
})
.live("draginit", function(){
.on("draginit", '#drag', function(){
drags.draginit = true;
})
.live("dragmove", function(){
.on("dragmove", '#drag', function(){
drags.dragmove = true;
})
.live("dragend", function(){
.on("dragend", '#drag', function(){
drags.dragend = true;
})
.live("dragover", function(){
.on("dragover", '#drag', function(){
drags.dragover = true;
})
.live("dragout", function(){
.on("dragout", '#drag', function(){
drags.dragout = true;
})
.live("dragcleanup", function() {
.on("dragcleanup", '#drag', function() {
drags.dragcleanup = true;
})
$('#drop')
.live("dropinit", function(){
$("#qunit-test-area")
.on("dropinit",'#drop', function(){
drops.dropinit = true;
})
.live("dropover", function(){
.on("dropover",'#drop', function(){
drops.dropover = true;
})
.live("dropout", function(){
.on("dropout",'#drop', function(){
drops.dropout = true;
})
.live("dropmove", function(){
.on("dropmove",'#drop', function(){
drops.dropmove = true;
})
.live("dropon", function(){
.on("dropon",'#drop', function(){
drops.dropon = true;
})
.live("dropend", function(){
.on("dropend",'#drop', function(){
drops.dropend = true;
})
@@ -113,6 +113,7 @@ test("dragging an element", function(){
ok(drops.dropout, "dropout fired correctly")
//div.remove();
start();
$("#qunit-test-area").off()
})
})
@@ -155,7 +156,7 @@ test("drag position", function(){
var drags = {}, drops ={};
$('#drag').live("draginit", function(){
$("#qunit-test-area").on("draginit",'#drag', function(){
drags.draginit = true;
})
var offset = $('#drag').offset();
@@ -167,6 +168,7 @@ test("drag position", function(){
equals(offset.top+20, Math.ceil(offset2.top), "top")
equals(offset.left+20, Math.ceil(offset2.left), "left")
start();
$("#qunit-test-area").off()
})
});
@@ -219,8 +221,10 @@ test("dragdown" , function(){
equals(offset.top+20, Math.ceil(offset2.top), "top")
equals(offset.left+20, Math.ceil(offset2.left), "left")
// IE doesn't respect preventDefault on text inputs (http://www.quirksmode.org/dom/events/click.html)
if(!$.browser.msie)
if(!document.body.attachEvent) {
ok(draginpfocused, "First input was allowed to be focused correctly");
}
//ok(!dragnopreventfocused, "Second input was not allowed to focus");
start();
})
Oops, something went wrong.

0 comments on commit 692ed50

Please sign in to comment.