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

59 lines
1.4 KiB
JavaScript
Raw Normal View History

define( [
"jquery",
"ui/widgets/progressbar"
], function( $ ) {
2012-05-26 03:10:46 +00:00
module( "progressbar: events" );
2012-05-26 03:10:46 +00:00
test( "create", function() {
expect( 1 );
$( "#progressbar" ).progressbar({
value: 5,
create: function() {
2012-12-06 14:50:33 +00:00
equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
},
change: function() {
2012-12-06 14:50:33 +00:00
ok( false, "create has triggered change()" );
}
2012-04-19 02:46:39 +00:00
});
});
2012-05-26 03:10:46 +00:00
test( "change", function() {
2012-12-06 14:50:33 +00:00
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() {
2012-12-06 14:50:33 +00:00
expect( 5 );
2012-05-26 03:10:46 +00:00
var value,
changes = 0,
element = $( "#progressbar" ).progressbar({
change: function() {
changes++;
2012-12-06 14:50:33 +00:00
equal( element.progressbar( "value" ), value, "change at " + value );
2012-05-26 03:10:46 +00:00
},
complete: function() {
equal( changes, 3, "complete triggered after change and not on indeterminate" );
2012-12-06 14:50:33 +00:00
equal( element.progressbar( "value" ), 100, "value is 100" );
2012-05-26 03:10:46 +00:00
}
});
value = 5;
2012-05-26 03:10:46 +00:00
element.progressbar( "value", value );
value = false;
element.progressbar( "value", value );
value = 100;
2012-05-26 03:10:46 +00:00
element.progressbar( "value", value );
});
} );