Skip to content
Permalink
Browse files

Progress tests: Cleanup.

  • Loading branch information...
scottgonzalez committed Dec 6, 2012
1 parent f1be88e commit 9d0df536240f1b5e84d1f772ef95117280acd4d8
@@ -5,34 +5,40 @@ test( "create", function() {
$( "#progressbar" ).progressbar({
value: 5,
create: function() {
deepEqual( 5, $( this ).progressbar( "value" ) );
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
},
change: function() {
ok( false, "create() has triggered change()" );
ok( false, "create has triggered change()" );
}
});
});

test( "change", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
change: function() {
deepEqual( 5, $( this ).progressbar( "value" ) );
}
}).progressbar( "value", 5 );
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( 4 );
expect( 5 );
var value,
changes = 0,
element = $( "#progressbar" ).progressbar({
change: function() {
changes++;
deepEqual( element.progressbar( "value" ), value, "change at " + value );
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" );
}
});

@@ -12,7 +12,7 @@ test( "value", function() {

var element = $( "<div>" ).progressbar({ value: 20 });
equal( element.progressbar( "value" ), 20, "correct value as getter" );
equal( element.progressbar( "value", 30), element, "chainable as setter" );
strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" );
equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
});

@@ -1,14 +1,14 @@
module( "progressbar: options" );

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

// Ticket #7231 - valueDiv should be hidden when value is at 0%
test( "value: visibility of valueDiv", function() {
expect( 5 );
expect( 4 );
var element = $( "#progressbar" ).progressbar({
value: 0
});
@@ -23,58 +23,50 @@ test( "value: visibility of valueDiv", function() {
element.progressbar( "value", 0 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is set to 0" );
element.progressbar( "value", -1 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value set to -1 (normalizes to 0)" );
});

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

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

test( "{ value : 105 }", function() {
test( "{ value: 105 }", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
value: 105
});
deepEqual( 100, $( "#progressbar" ).progressbar( "value" ) );
});

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

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

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

0 comments on commit 9d0df53

Please sign in to comment.
You can’t perform that action at this time.