aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/staticfiles/plugins/jquery-ui/tests/unit/progressbar/progressbar_events.js
blob: 95effda7511aab49bbe6608d91ed37a8ef886db4 (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
module( "progressbar: events" );

test( "create", function() {
	expect( 1 );
	$( "#progressbar" ).progressbar({
		value: 5,
		create: function() {
			equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
		},
		change: function() {
			ok( false, "create has triggered change()" );
		}
	});
});

test( "change", function() {
	expect( 2 );
	var element = $( "#progressbar" ).progressbar();

	element.one( "progressbarchange", function() {
		equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
	});
	element.progressbar( "value", 5 );
	element.one( "progressbarchange", function() {
		equal( element.progressbar( "value" ), 100, "change triggered for final value" );
	});
	element.progressbar( "value", 100 );
});

test( "complete", function() {
	expect( 5 );
	var value,
		changes = 0,
		element = $( "#progressbar" ).progressbar({
			change: function() {
				changes++;
				equal( element.progressbar( "value" ), value, "change at " + value );
			},
			complete: function() {
				equal( changes, 3, "complete triggered after change and not on indeterminate" );
				equal( element.progressbar( "value" ), 100, "value is 100" );
			}
		});

	value = 5;
	element.progressbar( "value", value );
	value = false;
	element.progressbar( "value", value );
	value = 100;
	element.progressbar( "value", value );
});