2015-04-06 18:27:05 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-07-15 02:04:22 +00:00
|
|
|
"ui/widgets/progressbar"
|
2015-04-06 18:27:05 +00:00
|
|
|
], function( $ ) {
|
2015-01-25 14:39:06 +00:00
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
module( "progressbar: options" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "{ value: 0 }, default", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 1 );
|
2012-05-26 03:10:46 +00:00
|
|
|
$( "#progressbar" ).progressbar();
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 0 );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2009-09-11 18:47:34 +00:00
|
|
|
|
2011-04-09 18:53:15 +00:00
|
|
|
// Ticket #7231 - valueDiv should be hidden when value is at 0%
|
|
|
|
test( "value: visibility of valueDiv", function() {
|
2012-12-06 14:50:33 +00:00
|
|
|
expect( 4 );
|
2015-08-24 12:58:48 +00:00
|
|
|
var element = $( "#progressbar" ).progressbar( {
|
2011-04-09 18:53:15 +00:00
|
|
|
value: 0
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-05-26 03:10:46 +00:00
|
|
|
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
|
|
|
|
"valueDiv hidden when value is initialized at 0" );
|
2011-04-09 18:53:15 +00:00
|
|
|
element.progressbar( "value", 1 );
|
2012-05-26 03:10:46 +00:00
|
|
|
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
|
|
|
|
"valueDiv visible when value is set to 1" );
|
2011-04-09 18:53:15 +00:00
|
|
|
element.progressbar( "value", 100 );
|
2012-05-26 03:10:46 +00:00
|
|
|
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
|
|
|
|
"valueDiv visible when value is set to 100" );
|
2011-04-09 18:53:15 +00:00
|
|
|
element.progressbar( "value", 0 );
|
2012-05-26 03:10:46 +00:00
|
|
|
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
|
|
|
|
"valueDiv hidden when value is set to 0" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2011-04-09 18:53:15 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "{ value: 5 }", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2009-09-11 18:47:34 +00:00
|
|
|
value: 5
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 5 );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "{ value: -5 }", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2010-07-29 09:38:24 +00:00
|
|
|
value: -5
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 0,
|
|
|
|
"value constrained at min" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2010-07-29 09:38:24 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "{ value: 105 }", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2010-07-29 09:38:24 +00:00
|
|
|
value: 105
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 100,
|
|
|
|
"value constrained at max" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-11-08 18:02:25 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "{ value: 10, max: 5 }", function() {
|
2012-11-08 18:02:25 +00:00
|
|
|
expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2012-11-08 18:02:25 +00:00
|
|
|
max: 5,
|
|
|
|
value: 10
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 5,
|
|
|
|
"value constrained at max" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2012-11-08 18:02:25 +00:00
|
|
|
|
2012-12-06 14:50:33 +00:00
|
|
|
test( "change max below value", function() {
|
2012-11-08 18:02:25 +00:00
|
|
|
expect( 1 );
|
2015-08-24 12:58:48 +00:00
|
|
|
$( "#progressbar" ).progressbar( {
|
2012-11-08 18:02:25 +00:00
|
|
|
max: 10,
|
|
|
|
value: 10
|
2015-08-24 12:58:48 +00:00
|
|
|
} ).progressbar( "option", "max", 5 );
|
2012-12-06 14:50:33 +00:00
|
|
|
equal( $( "#progressbar" ).progressbar( "value" ), 5,
|
|
|
|
"value constrained at max" );
|
2015-08-24 12:58:48 +00:00
|
|
|
} );
|
2015-01-25 14:39:06 +00:00
|
|
|
|
2015-04-06 18:27:05 +00:00
|
|
|
} );
|