aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorAnton M <obhvsbypqghgc@gmail.com>2011-02-10 03:18:11 +0100
committerAnton M <obhvsbypqghgc@gmail.com>2011-02-10 22:20:48 +0100
commit78fc79fad47ce2991c0a7148b65acd7221223eb9 (patch)
tree64c93cf8a10d490510300035a91741ad1f7b85ff /test/unit
parent4490f4285cc4cdafba67fee726d3eba4a3d81a0f (diff)
downloadjquery-78fc79fad47ce2991c0a7148b65acd7221223eb9.tar.gz
jquery-78fc79fad47ce2991c0a7148b65acd7221223eb9.zip
Make sure .clone(true) correctly clones namespaced events. Fixes #4537.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/event.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index 21ed63166..1d9e2e110 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -361,9 +361,7 @@ test("bind(), trigger change on select", function() {
}).trigger('change');
});
-test("bind(), namespaced events, cloned events", function() {
- expect(6);
-
+test("bind(), namespaced events, cloned events", 18, function() {
var firstp = jQuery( "#firstp" );
firstp.bind("custom.test",function(e){
@@ -372,22 +370,31 @@ test("bind(), namespaced events, cloned events", function() {
firstp.bind("click",function(e){
ok(true, "Normal click triggered");
+ equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" );
});
firstp.bind("click.test",function(e){
+ var check = "click";
ok( true, "Namespaced click triggered" );
+ if ( e.namespace ) {
+ check += "test";
+ }
+ equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" );
});
- // Trigger both bound fn (2)
+ //clone(true) element to verify events are cloned correctly
+ firstp = firstp.add( firstp.clone( true ).attr( "id", "firstp2" ).insertBefore( firstp ) );
+
+ // Trigger both bound fn (8)
firstp.trigger("click");
- // Trigger one bound fn (1)
+ // Trigger one bound fn (4)
firstp.trigger("click.test");
// Remove only the one fn
firstp.unbind("click.test");
- // Trigger the remaining fn (1)
+ // Trigger the remaining fn (4)
firstp.trigger("click");
// Remove the remaining namespaced fn