2015-04-06 19:07:04 +00:00
|
|
|
define( [
|
2016-04-06 14:06:47 +00:00
|
|
|
"qunit",
|
2015-04-06 19:07:04 +00:00
|
|
|
"jquery",
|
|
|
|
"ui/widget"
|
2016-04-06 14:06:47 +00:00
|
|
|
], function( QUnit, $ ) {
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.module( "widget animation", ( function() {
|
2011-05-30 22:27:48 +00:00
|
|
|
var show = $.fn.show,
|
|
|
|
fadeIn = $.fn.fadeIn,
|
|
|
|
slideDown = $.fn.slideDown;
|
|
|
|
return {
|
2016-04-06 14:06:47 +00:00
|
|
|
beforeEach: function() {
|
2011-05-30 22:27:48 +00:00
|
|
|
$.widget( "ui.testWidget", {
|
|
|
|
_create: function() {
|
|
|
|
this.element.hide();
|
|
|
|
},
|
|
|
|
show: function( fn ) {
|
|
|
|
this._show( this.element, this.options.show, fn );
|
|
|
|
}
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
$.effects = { effect: { testEffect: $.noop } };
|
|
|
|
},
|
2016-04-06 14:06:47 +00:00
|
|
|
afterEach: function() {
|
2011-05-30 22:27:48 +00:00
|
|
|
delete $.ui.testWidget;
|
|
|
|
delete $.effects.effect.testEffect;
|
|
|
|
$.fn.show = show;
|
|
|
|
$.fn.fadeIn = fadeIn;
|
|
|
|
$.fn.slideDown = slideDown;
|
|
|
|
}
|
|
|
|
};
|
2015-08-24 13:32:13 +00:00
|
|
|
}() ) );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: null", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
|
|
|
var element = $( "#widget" ).testWidget(),
|
|
|
|
hasRun = false;
|
|
|
|
$.fn.show = function() {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( true, "show called" );
|
|
|
|
assert.equal( arguments.length, 0, "no args passed to show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: true", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: true
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.fadeIn = function( duration, easing, complete ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.strictEqual( duration, undefined, "duration" );
|
|
|
|
assert.strictEqual( easing, undefined, "easing" );
|
2011-05-30 22:27:48 +00:00
|
|
|
complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: number", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: 123
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.fadeIn = function( duration, easing, complete ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.strictEqual( duration, 123, "duration" );
|
|
|
|
assert.strictEqual( easing, undefined, "easing" );
|
2011-05-30 22:27:48 +00:00
|
|
|
complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: core animation", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: "slideDown"
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.slideDown = function( duration, easing, complete ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.strictEqual( duration, undefined, "duration" );
|
|
|
|
assert.strictEqual( easing, undefined, "easing" );
|
2011-05-30 22:27:48 +00:00
|
|
|
complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: effect", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 5 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: "testEffect"
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.show = function( options ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.equal( options.effect, "testEffect", "effect" );
|
|
|
|
assert.ok( !( "duration" in options ), "duration" );
|
|
|
|
assert.ok( !( "easing" in options ), "easing" );
|
2011-05-30 22:27:48 +00:00
|
|
|
options.complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: object(core animation)", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: {
|
|
|
|
effect: "slideDown",
|
|
|
|
duration: 123,
|
|
|
|
easing: "testEasing"
|
|
|
|
}
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.slideDown = function( duration, easing, complete ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.equal( duration, 123, "duration" );
|
|
|
|
assert.equal( easing, "testEasing", "easing" );
|
2011-05-30 22:27:48 +00:00
|
|
|
complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2016-04-06 14:06:47 +00:00
|
|
|
QUnit.test( "show: object(effect)", function( assert ) {
|
|
|
|
var ready = assert.async();
|
|
|
|
assert.expect( 3 );
|
2011-05-30 22:27:48 +00:00
|
|
|
|
2015-08-24 13:32:13 +00:00
|
|
|
var element = $( "#widget" ).testWidget( {
|
2011-05-30 22:27:48 +00:00
|
|
|
show: {
|
|
|
|
effect: "testEffect",
|
|
|
|
duration: 123,
|
|
|
|
easing: "testEasing"
|
|
|
|
}
|
2015-08-24 13:32:13 +00:00
|
|
|
} ),
|
2011-05-30 22:27:48 +00:00
|
|
|
hasRun = false;
|
|
|
|
$.fn.show = function( options ) {
|
2015-08-24 13:32:13 +00:00
|
|
|
return this.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.deepEqual( options, {
|
2011-05-30 22:27:48 +00:00
|
|
|
effect: "testEffect",
|
|
|
|
duration: 123,
|
|
|
|
easing: "testEasing",
|
|
|
|
complete: options.complete
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
options.complete();
|
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
2011-05-30 22:27:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
element
|
|
|
|
.delay( 50 )
|
2015-08-24 13:32:13 +00:00
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( !hasRun, "queue before show" );
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
2011-05-30 22:27:48 +00:00
|
|
|
.testWidget( "show", function() {
|
|
|
|
hasRun = true;
|
2015-08-24 13:32:13 +00:00
|
|
|
} )
|
|
|
|
.queue( function( next ) {
|
2016-04-06 14:06:47 +00:00
|
|
|
assert.ok( hasRun, "queue after show" );
|
|
|
|
ready();
|
2011-05-30 22:27:48 +00:00
|
|
|
next();
|
2015-08-24 13:32:13 +00:00
|
|
|
} );
|
|
|
|
} );
|
2015-04-06 19:07:04 +00:00
|
|
|
|
|
|
|
} );
|