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

66 lines
2.6 KiB
JavaScript
Raw Normal View History

define( [
2016-04-06 13:08:28 +00:00
"qunit",
"jquery",
"ui/widgets/progressbar"
2016-04-06 13:08:28 +00:00
], function( QUnit, $ ) {
2016-04-06 13:08:28 +00:00
QUnit.module( "progressbar: core" );
2016-04-06 13:08:28 +00:00
QUnit.test( "markup structure", function( assert ) {
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" );
2016-04-06 13:08:28 +00:00
assert.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" );
2016-04-06 13:08:28 +00:00
assert.equal( element.children().children().length, 0, "no overlay div" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "markup structure - indeterminate", function( assert ) {
assert.expect( 5 );
2015-08-24 12:58:48 +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" );
2016-04-06 13:08:28 +00:00
assert.equal( children.length, 1, "Main element contains one child" );
assert.hasClasses( children[ 0 ], "ui-progressbar-value" );
2016-04-06 13:08:28 +00:00
assert.equal( children.children( ".ui-progressbar-overlay" ).length, 1,
"Value has class ui-progressbar-overlay" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "accessibility", function( assert ) {
assert.expect( 11 );
2012-05-26 03:10:46 +00:00
var element = $( "#progressbar" ).progressbar();
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "role" ), "progressbar", "aria role" );
assert.equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
assert.equal( element.attr( "aria-valuemax" ), 100, "aria-valuemax" );
assert.equal( element.attr( "aria-valuenow" ), 0, "aria-valuenow initially" );
2012-05-26 03:10:46 +00:00
element.progressbar( "value", 77 );
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );
element.progressbar( "option", "max", 150 );
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
2012-05-26 03:10:46 +00:00
element.progressbar( "disable" );
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );
2012-05-26 03:10:46 +00:00
element.progressbar( "enable" );
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );
element.progressbar( "option", "value", false );
2016-04-06 13:08:28 +00:00
assert.equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
assert.equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );
assert.equal( element.attr( "aria-valuenow" ), null, "aria-valuenow" );
2015-08-24 12:58:48 +00:00
} );
} );