aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/progressbar/options.js
blob: fa88ae3c2df36da0c05f54edc358a9284867d582 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
define( [
	"qunit",
	"jquery",
	"lib/helper",
	"ui/widgets/progressbar"
], function( QUnit, $, helper ) {

QUnit.module( "progressbar: options", { afterEach: helper.moduleAfterEach }  );

QUnit.test( "{ value: 0 }, default", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar();
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 0 );
} );

// Ticket #7231 - valueDiv should be hidden when value is at 0%
QUnit.test( "value: visibility of valueDiv", function( assert ) {
	assert.expect( 4 );
	var element = $( "#progressbar" ).progressbar( {
		value: 0
	} );
	assert.ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
		"valueDiv hidden when value is initialized at 0" );
	element.progressbar( "value", 1 );
	assert.ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
		"valueDiv visible when value is set to 1" );
	element.progressbar( "value", 100 );
	assert.ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
		"valueDiv visible when value is set to 100" );
	element.progressbar( "value", 0 );
	assert.ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
		"valueDiv hidden when value is set to 0" );
} );

QUnit.test( "{ value: 5 }", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar( {
		value: 5
	} );
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 5 );
} );

QUnit.test( "{ value: -5 }", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar( {
		value: -5
	} );
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 0,
		"value constrained at min" );
} );

QUnit.test( "{ value: 105 }", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar( {
		value: 105
	} );
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 100,
		"value constrained at max" );
} );

QUnit.test( "{ value: 10, max: 5 }", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar( {
		max: 5,
		value: 10
	} );
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 5,
		"value constrained at max" );
} );

QUnit.test( "change max below value", function( assert ) {
	assert.expect( 1 );
	$( "#progressbar" ).progressbar( {
		max: 10,
		value: 10
	} ).progressbar( "option", "max", 5 );
	assert.equal( $( "#progressbar" ).progressbar( "value" ), 5,
		"value constrained at max" );
} );

} );