aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/progressbar/core.js
blob: b25032a407f52eea86a3259c2504a40113ed0f19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
define( [
	"qunit",
	"jquery",
	"ui/widgets/progressbar"
], function( QUnit, $ ) {

QUnit.module( "progressbar: core" );

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" );
	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" );
	assert.equal( element.children().children().length, 0, "no overlay div" );
} );

QUnit.test( "markup structure - indeterminate", function( assert ) {
	assert.expect( 5 );
	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" );
	assert.equal( children.length, 1, "Main element contains one child" );
	assert.hasClasses( children[ 0 ], "ui-progressbar-value" );
	assert.equal( children.children( ".ui-progressbar-overlay" ).length, 1,
		"Value has class ui-progressbar-overlay" );
} );

QUnit.test( "accessibility", function( assert ) {
	assert.expect( 11 );
	var element = $( "#progressbar" ).progressbar();

	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" );

	element.progressbar( "value", 77 );
	assert.equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );

	element.progressbar( "option", "max", 150 );
	assert.equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" );

	element.progressbar( "disable" );
	assert.equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );

	element.progressbar( "enable" );
	assert.equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );

	element.progressbar( "option", "value", false );
	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" );
} );

} );