3 const { JSDOM } = require( "jsdom" );
5 const { window } = new JSDOM( "" );
7 const jQuery = require( "../../" )( window );
9 module.exports.deferred = () => {
10 let adopted, promised;
15 adopted = jQuery.when.apply( jQuery, arguments );
17 adopted.then( promised.resolve, promised.reject );
22 reject: function( value ) {
24 adopted = jQuery.when( jQuery.Deferred().reject( value ) );
26 adopted.then( promised.resolve, promised.reject );
32 // A manually-constructed thenable that works even if calls precede resolve/reject
37 promised = jQuery.Deferred();
39 return promised.then.apply( promised, arguments );
41 return adopted.then.apply( adopted, arguments );