2015-01-25 14:39:06 +00:00
|
|
|
(function( $ ) {
|
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
module( "progressbar: core" );
|
2009-02-04 04:39:31 +00:00
|
|
|
|
2014-12-03 16:25:32 +00:00
|
|
|
test( "markup structure", function( assert ) {
|
|
|
|
expect( 7 );
|
|
|
|
var element = $( "#progressbar" ).progressbar(),
|
|
|
|
value = element.children().eq( 0 );
|
|
|
|
|
|
|
|
assert.hasClasses( element, "ui-progressbar ui-widget ui-widget-content" );
|
|
|
|
assert.hasClasses( value, "ui-progressbar-value ui-widget-header" );
|
|
|
|
assert.lacksClasses( value, "ui-progressbar-complete" );
|
|
|
|
assert.lacksClasses( element, "ui-progressbar-indeterminate" );
|
|
|
|
equal( element.children().length, 1, "Main element contains one child" );
|
|
|
|
|
|
|
|
element.progressbar( "option", "value", 100 );
|
|
|
|
assert.hasClasses( value, "ui-progressbar-complete ui-widget-header ui-progressbar-value" );
|
2012-12-12 16:21:49 +00:00
|
|
|
equal( element.children().children().length, 0, "no overlay div" );
|
|
|
|
});
|
|
|
|
|
2014-12-03 16:25:32 +00:00
|
|
|
test( "markup structure - indeterminate", function( assert ) {
|
2012-12-12 16:21:49 +00:00
|
|
|
expect( 5 );
|
2014-12-03 16:25:32 +00:00
|
|
|
var element = $( "#progressbar" ).progressbar({ value: false }),
|
|
|
|
children = element.children();
|
|
|
|
|
|
|
|
assert.hasClasses( element, "ui-progressbar ui-progressbar-indeterminate ui-widget ui-widget-content" );
|
|
|
|
assert.hasClasses( children[ 0 ], "ui-progressbar-value ui-widget-header" );
|
|
|
|
equal( children.length, 1, "Main element contains one child" );
|
|
|
|
assert.hasClasses( children[ 0 ], "ui-progressbar-value" );
|
|
|
|
equal( children.children( ".ui-progressbar-overlay" ).length, 1,
|
|
|
|
"Value has class ui-progressbar-overlay" );
|
2012-12-12 16:21:49 +00:00
|
|
|
});
|
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
test( "accessibility", function() {
|
2012-12-06 14:35:41 +00:00
|
|
|
expect( 11 );
|
2012-05-26 03:10:46 +00:00
|
|
|
var element = $( "#progressbar" ).progressbar();
|
2009-02-04 04:39:31 +00:00
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
equal( element.attr( "role" ), "progressbar", "aria role" );
|
|
|
|
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
|
|
|
|
equal( element.attr( "aria-valuemax" ), 100, "aria-valuemax" );
|
|
|
|
equal( element.attr( "aria-valuenow" ), 0, "aria-valuenow initially" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
element.progressbar( "value", 77 );
|
|
|
|
equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-12-06 14:35:41 +00:00
|
|
|
element.progressbar( "option", "max", 150 );
|
|
|
|
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
|
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
element.progressbar( "disable" );
|
|
|
|
equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );
|
2009-02-04 04:39:31 +00:00
|
|
|
|
2012-05-26 03:10:46 +00:00
|
|
|
element.progressbar( "enable" );
|
|
|
|
equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );
|
2012-12-06 14:35:41 +00:00
|
|
|
|
|
|
|
element.progressbar( "option", "value", false );
|
|
|
|
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
|
|
|
|
equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
|
2012-12-06 15:10:07 +00:00
|
|
|
strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" );
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
2015-01-25 14:39:06 +00:00
|
|
|
|
|
|
|
}( jQuery ) );
|