mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Added unit tests to check and demonstrate new jQuery.Deferred() works.
This commit is contained in:
parent
5798446b98
commit
ac2e731b2d
@ -1003,7 +1003,7 @@ test("jQuery._Deferred()", function() {
|
|||||||
|
|
||||||
test("jQuery.Deferred()", function() {
|
test("jQuery.Deferred()", function() {
|
||||||
|
|
||||||
expect( 6 );
|
expect( 10 );
|
||||||
|
|
||||||
jQuery.Deferred( function( defer ) {
|
jQuery.Deferred( function( defer ) {
|
||||||
strictEqual( this , defer , "Defer passed as this & first argument" );
|
strictEqual( this , defer , "Defer passed as this & first argument" );
|
||||||
@ -1024,6 +1024,25 @@ test("jQuery.Deferred()", function() {
|
|||||||
ok( true , "Error on reject" );
|
ok( true , "Error on reject" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
( new jQuery.Deferred( function( defer ) {
|
||||||
|
strictEqual( this , defer , "Defer passed as this & first argument (new)" );
|
||||||
|
this.resolve( "done" );
|
||||||
|
}) ).then( function( value ) {
|
||||||
|
strictEqual( value , "done" , "Passed function executed (new)" );
|
||||||
|
});
|
||||||
|
|
||||||
|
( new jQuery.Deferred() ).resolve().then( function() {
|
||||||
|
ok( true , "Success on resolve (new)" );
|
||||||
|
}, function() {
|
||||||
|
ok( false , "Error on resolve (new)" );
|
||||||
|
});
|
||||||
|
|
||||||
|
( new jQuery.Deferred() ).reject().then( function() {
|
||||||
|
ok( false , "Success on reject (new)" );
|
||||||
|
}, function() {
|
||||||
|
ok( true , "Error on reject (new)" );
|
||||||
|
});
|
||||||
|
|
||||||
var tmp = jQuery.Deferred();
|
var tmp = jQuery.Deferred();
|
||||||
|
|
||||||
strictEqual( tmp.promise() , tmp.promise() , "Test deferred always return same promise" );
|
strictEqual( tmp.promise() , tmp.promise() , "Test deferred always return same promise" );
|
||||||
|
Loading…
Reference in New Issue
Block a user