3 test("toggle(Function, Function) - add toggle event and fake a few clicks", function() {
6 fn1 = function(e) { count++; },
7 fn2 = function(e) { count--; },
8 preventDefault = function(e) { e.preventDefault() },
10 if ( $.browser.msie || $.browser.opera || /konquerer/i.test(navigator.userAgent) )
11 ok( false, "click() on link gets executed in IE/Opera/Konquerer, not intended behaviour!" );
13 link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
14 ok( count == 1, "Check for toggle(fn, fn)" );
17 test("unbind(event)", function() {
19 var el = $("#firstp");
21 ok( true, "Fake normal bind" );
23 el.click(function(event) {
25 ok( true, "Fake onebind" );
29 el.click(function() { return; });
31 ok( !el[0].onclick, "Handler is removed" ); // Bug #964
33 el.click(function() { return; });
34 el.unbind('change',function(){ return; });
35 ok( el[0].onclick, "Extra handlers weren't accidentally removed." );
38 ok( !el[0].$events, "Removed the events expando after all handlers are unbound." );
41 test("trigger(event, [data]", function() {
43 var handler = function(event, a, b, c) {
44 ok( a == 1, "check passed data" );
45 ok( b == "2", "check passed data" );
46 ok( c == "abc", "check passed data" );
48 $("#firstp").bind("click", handler).trigger("click", [1, "2", "abc"]);
51 test("bind() with data", function() {
53 var handler = function(event) {
54 ok( event.data, "check passed data exists" );
55 ok( event.data.foo == "bar", "Check value of passed data" );
57 $("#firstp").bind("click", {foo: "bar"}, handler).click();
60 test("bind() with data and trigger() with data", function() {
62 var handler = function(event, data) {
63 ok( event.data, "check passed data exists" );
64 ok( event.data.foo == "bar", "Check value of passed data" );
65 ok( data, "Check trigger data" );
66 ok( data.bar == "foo", "Check value of trigger data" );
68 $("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]);