2015-04-06 18:27:05 +00:00
|
|
|
define( [
|
2016-04-06 13:08:28 +00:00
|
|
|
"qunit",
|
2015-04-06 18:27:05 +00:00
|
|
|
"jquery",
|
2015-07-15 02:04:22 +00:00
|
|
|
"ui/widgets/progressbar"
|
2016-04-06 13:08:28 +00:00
|
|
|
], function( QUnit, $ ) {
|
2015-01-25 14:39:06 +00:00
|
|
|
|
2016-04-06 13:08:28 +00:00
|
|
|
QUnit.module( "progressbar: events" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-06 13:08:28 +00:00
|
|
|
QUnit.test( "create", function( assert ) {
|
|
|
|
assert.expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2010-11-22 13:49:47 +00:00
|
|
|
value: 5,
|
|
|
|
create: function() {
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
|
2010-11-22 13:49:47 +00:00
|
|
|
},
|
|
|
|
change: function() {
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.ok( false, "create has triggered change()" );
|
2010-11-22 13:49:47 +00:00
|
|
|
}
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
|
|
|
} );
|
2010-11-22 13:49:47 +00:00
|
|
|
|
2016-04-06 13:08:28 +00:00
|
|
|
QUnit.test( "change", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2012-12-06 14:50:33 +00:00
|
|
|
var element = $( "#progressbar" ).progressbar();
|
|
|
|
|
|
|
|
element.one( "progressbarchange", function() {
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
element.progressbar( "value", 5 );
|
|
|
|
element.one( "progressbarchange", function() {
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.equal( element.progressbar( "value" ), 100, "change triggered for final value" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
element.progressbar( "value", 100 );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2016-04-06 13:08:28 +00:00
|
|
|
QUnit.test( "complete", function( assert ) {
|
|
|
|
assert.expect( 5 );
|
2012-05-26 03:10:46 +00:00
|
|
|
var value,
|
|
|
|
changes = 0,
|
2015-08-24 12:58:48 +00:00
|
|
|
element = $( "#progressbar" ).progressbar( {
|
2012-05-26 03:10:46 +00:00
|
|
|
change: function() {
|
|
|
|
changes++;
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.equal( element.progressbar( "value" ), value, "change at " + value );
|
2012-05-26 03:10:46 +00:00
|
|
|
},
|
|
|
|
complete: function() {
|
2016-04-06 13:08:28 +00:00
|
|
|
assert.equal( changes, 3, "complete triggered after change and not on indeterminate" );
|
|
|
|
assert.equal( element.progressbar( "value" ), 100, "value is 100" );
|
2012-05-26 03:10:46 +00:00
|
|
|
}
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-02-28 14:56:32 +00:00
|
|
|
|
2010-09-27 14:44:04 +00:00
|
|
|
value = 5;
|
2012-05-26 03:10:46 +00:00
|
|
|
element.progressbar( "value", value );
|
2012-03-27 02:51:16 +00:00
|
|
|
value = false;
|
|
|
|
element.progressbar( "value", value );
|
2010-09-27 14:44:04 +00:00
|
|
|
value = 100;
|
2012-05-26 03:10:46 +00:00
|
|
|
element.progressbar( "value", value );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2015-01-25 14:39:06 +00:00
|
|
|
|
2015-04-06 18:27:05 +00:00
|
|
|
} );
|