Modified toggle() test to stop IE from browsing to another site, problem not solved
[jquery.git] / src / event / eventTest.js
1 module("event");
2
3 test("toggle(Function, Function) - add toggle event and fake a few clicks", function() {
4         expect(1);
5         var count = 0,
6                 fn1 = function(e) { count++; },
7                 fn2 = function(e) { count--; console.debug("fn"); },
8                 preventDefault = function(e) { e.preventDefault() },
9                 link = $('#mark');
10         if($.browser.msie)
11                 ok( false, "click() on link gets executed in IE, not intended behaviour!" );
12         else
13                 link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
14         ok( count == 1, "Check for toggle(fn, fn)" );
15 });
16
17 test("unbind(event)", function() {
18         expect(3);
19         var el = $("#firstp");
20         el.click(function() {
21                 ok( true, "Fake normal bind" );
22         });
23         el.click(function(event) {
24                 el.unbind(event);
25                 ok( true, "Fake onebind" );
26         });
27         el.click().click();
28 });
29
30 test("trigger(event, [data]", function() {
31         expect(3);
32         var handler = function(event, a, b, c) {
33                 ok( a == 1, "check passed data" );
34                 ok( b == "2", "check passed data" );
35                 ok( c == "abc", "check passed data" );
36         }
37         $("#firstp").bind("click", handler).trigger("click", [1, "2", "abc"]);
38 });
39
40 test("bind() with data", function() {
41         expect(2);
42         var handler = function(event) {
43                 ok( event.data, "check passed data exists" );
44                 ok( event.data.foo == "bar", "Check value of passed data" );
45         }
46         $("#firstp").bind("click", {foo: "bar"}, handler).click();
47 });
48
49 test("bind() with data and trigger() with data", function() {
50         expect(4);
51         var handler = function(event, data) {
52                 ok( event.data, "check passed data exists" );
53                 ok( event.data.foo == "bar", "Check value of passed data" );
54                 ok( data, "Check trigger data" );
55                 ok( data.bar == "foo", "Check value of trigger data" );
56         }
57         $("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]);
58 });