jquery-ui/tests/unit/progressbar/options.js

83 lines
2.3 KiB
JavaScript
Raw Normal View History

define( [
2016-04-06 13:08:28 +00:00
"qunit",
"jquery",
"lib/helper",
"ui/widgets/progressbar"
], function( QUnit, $, helper ) {
"use strict";
QUnit.module( "progressbar: options", { afterEach: helper.moduleAfterEach } );
2016-04-06 13:08:28 +00:00
QUnit.test( "{ value: 0 }, default", function( assert ) {
assert.expect( 1 );
2012-05-26 03:10:46 +00:00
$( "#progressbar" ).progressbar();
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 0 );
2015-08-24 12:58:48 +00:00
} );
2009-09-11 18:47:34 +00:00
// Ticket #7231 - valueDiv should be hidden when value is at 0%
2016-04-06 13:08:28 +00:00
QUnit.test( "value: visibility of valueDiv", function( assert ) {
assert.expect( 4 );
2015-08-24 12:58:48 +00:00
var element = $( "#progressbar" ).progressbar( {
value: 0
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
assert.ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
2012-05-26 03:10:46 +00:00
"valueDiv hidden when value is initialized at 0" );
element.progressbar( "value", 1 );
2016-04-06 13:08:28 +00:00
assert.ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
2012-05-26 03:10:46 +00:00
"valueDiv visible when value is set to 1" );
element.progressbar( "value", 100 );
2016-04-06 13:08:28 +00:00
assert.ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
2012-05-26 03:10:46 +00:00
"valueDiv visible when value is set to 100" );
element.progressbar( "value", 0 );
2016-04-06 13:08:28 +00:00
assert.ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
2012-05-26 03:10:46 +00:00
"valueDiv hidden when value is set to 0" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "{ value: 5 }", function( assert ) {
assert.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
} );
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 5 );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "{ value: -5 }", function( assert ) {
assert.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
} );
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 0,
2012-12-06 14:50:33 +00:00
"value constrained at min" );
2015-08-24 12:58:48 +00:00
} );
2010-07-29 09:38:24 +00:00
2016-04-06 13:08:28 +00:00
QUnit.test( "{ value: 105 }", function( assert ) {
assert.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
} );
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 100,
2012-12-06 14:50:33 +00:00
"value constrained at max" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "{ value: 10, max: 5 }", function( assert ) {
assert.expect( 1 );
2015-08-24 12:58:48 +00:00
$( "#progressbar" ).progressbar( {
max: 5,
value: 10
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 5,
2012-12-06 14:50:33 +00:00
"value constrained at max" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "change max below value", function( assert ) {
assert.expect( 1 );
2015-08-24 12:58:48 +00:00
$( "#progressbar" ).progressbar( {
max: 10,
value: 10
2015-08-24 12:58:48 +00:00
} ).progressbar( "option", "max", 5 );
2016-04-06 13:08:28 +00:00
assert.equal( $( "#progressbar" ).progressbar( "value" ), 5,
2012-12-06 14:50:33 +00:00
"value constrained at max" );
2015-08-24 12:58:48 +00:00
} );
} );