swipe_test.js 2.02 KB
Newer Older
addyosmani's avatar
addyosmani committed
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
steal.plugins('funcunit/qunit','funcunit/syn','jquery/event/swipe').then(function(){

module("jquery/swipe", {setup : function(){
	$("#qunit-test-area").html("")
	var div = $("<div id='outer'>"+
			"<div id='inner1'>one</div>"+
			"<div id='inner2'>two<div id='inner3'>three</div></div>"+
			"</div>");
	
	div.appendTo($("#qunit-test-area"));
	var basicCss = {
		position: "absolute",
		border: "solid 1px black"
	}
	$("#outer").css(basicCss).css({top: "10px", left: "10px", 
		zIndex: 1000, backgroundColor: "green", width: "200px", height: "200px"})
}});

test("swipe right event",2, function(){
	
	$("#outer").bind("swipe",function(){
		ok(true,"swipe called");
	}).bind("swipeleft", function(){
		ok(false, "swipe left")
	}).bind("swiperight", function(){
		ok(true, "swiperight")
	});
	stop();
	Syn.drag({
		from: "20x20",
		to: "50x20",
		duration: 100,
	},"outer", function(){
		start();
	})
	
});


test("swipe left event",2, function(){
	
	$("#outer").bind("swipe",function(){
		ok(true,"swipe called");
	}).bind("swipeleft", function(){
		ok(true, "swipe left")
	}).bind("swiperight", function(){
		ok(false, "swiperight")
	});
	stop();
	Syn.drag({
		from: "50x20",
		to: "20x20",
		duration: 100,
	},"outer", function(){
		start();
	})
	
});


test("swipe up event",2, function(){
	
	$("#outer").bind("swipe",function(){
		ok(true,"swipe called");
	}).bind("swipeup", function(){
		ok(true, "swipe left")
	}).bind("swiperight", function(){
		ok(false, "swiperight")
	}).bind("swipedown", function(){
		ok(false, "swipedown")
	});
	stop();
	Syn.drag({
		from: "20x50",
		to: "20x20",
		duration: 100,
	},"outer", function(){
		start();
	})
	
});

test("swipe down event",2, function(){
	
	$("#outer").bind("swipe",function(){
		ok(true,"swipe called");
	}).bind("swipeup", function(){
		ok(false, "swipe left")
	}).bind("swiperight", function(){
		ok(false, "swiperight")
	}).bind("swipedown", function(){
		ok(true, "swipedown")
	});
	stop();
	Syn.drag({
		from: "20x20",
		to: "20x50",
		duration: 100,
	},"outer", function(){
		start();
	})
	
});






})