2015-08-16 06:59:58 +00:00
|
|
|
QUnit.module( "deprecated", { teardown: moduleTeardown } );
|
2013-04-08 22:18:45 +00:00
|
|
|
|
2015-10-01 20:03:10 +00:00
|
|
|
QUnit.test( "bind/unbind", function( assert ) {
|
|
|
|
assert.expect( 4 );
|
|
|
|
|
|
|
|
var markup = jQuery(
|
|
|
|
"<div><p><span><b>b</b></span></p></div>"
|
|
|
|
);
|
|
|
|
|
|
|
|
markup
|
|
|
|
.find( "b" )
|
|
|
|
.bind( "click", { bindData: 19 }, function( e, trig ) {
|
|
|
|
assert.equal( e.type, "click", "correct event type" );
|
|
|
|
assert.equal( e.data.bindData, 19, "correct trigger data" );
|
|
|
|
assert.equal( trig, 42, "correct bind data" );
|
2015-11-13 13:02:32 +00:00
|
|
|
assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" );
|
2015-10-01 20:03:10 +00:00
|
|
|
} )
|
|
|
|
.trigger( "click", [ 42 ] )
|
|
|
|
.unbind( "click" )
|
|
|
|
.trigger( "click" )
|
|
|
|
.remove();
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( "delegate/undelegate", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
|
|
|
|
|
|
|
var markup = jQuery(
|
|
|
|
"<div><p><span><b>b</b></span></p></div>"
|
|
|
|
);
|
|
|
|
|
|
|
|
markup
|
|
|
|
.delegate( "b", "click", function( e ) {
|
|
|
|
assert.equal( e.type, "click", "correct event type" );
|
2015-11-13 13:02:32 +00:00
|
|
|
assert.equal( e.target.nodeName.toLowerCase(), "b", "correct element" );
|
2015-10-01 20:03:10 +00:00
|
|
|
} )
|
|
|
|
.find( "b" )
|
|
|
|
.trigger( "click" )
|
|
|
|
.end()
|
|
|
|
.undelegate( "b", "click" )
|
|
|
|
.remove();
|
2015-11-13 13:02:32 +00:00
|
|
|
} );
|
2015-11-13 14:01:53 +00:00
|
|
|
if ( jQuery.fn.size ) {
|
2015-11-13 14:03:05 +00:00
|
|
|
QUnit.test("size()", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
|
|
|
assert.equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
|
2015-11-13 14:01:53 +00:00
|
|
|
});
|
|
|
|
}
|