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

60 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

define( [
2016-04-06 13:08:28 +00:00
"qunit",
"jquery",
"ui/widgets/progressbar"
2016-04-06 13:08:28 +00:00
], function( QUnit, $ ) {
2016-04-06 13:08:28 +00:00
QUnit.module( "progressbar: events" );
2016-04-06 13:08:28 +00:00
QUnit.test( "create", function( assert ) {
assert.expect( 1 );
2015-08-24 12:58:48 +00:00
$( "#progressbar" ).progressbar( {
value: 5,
create: function() {
2016-04-06 13:08:28 +00:00
assert.equal( $( this ).progressbar( "value" ), 5, "Correct value at create" );
},
change: function() {
2016-04-06 13:08:28 +00:00
assert.ok( false, "create has triggered change()" );
}
2015-08-24 12:58:48 +00:00
} );
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "change", function( assert ) {
assert.expect( 2 );
2012-12-06 14:50:33 +00:00
var element = $( "#progressbar" ).progressbar();
element.one( "progressbarchange", function() {
2016-04-06 13:08:28 +00:00
assert.equal( element.progressbar( "value" ), 5, "change triggered for middle value" );
2015-08-24 12:58:48 +00:00
} );
2012-12-06 14:50:33 +00:00
element.progressbar( "value", 5 );
element.one( "progressbarchange", function() {
2016-04-06 13:08:28 +00:00
assert.equal( element.progressbar( "value" ), 100, "change triggered for final value" );
2015-08-24 12:58:48 +00:00
} );
2012-12-06 14:50:33 +00:00
element.progressbar( "value", 100 );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "complete", function( assert ) {
assert.expect( 5 );
2012-05-26 03:10:46 +00:00
var value,
changes = 0,
2015-08-24 12:58:48 +00:00
element = $( "#progressbar" ).progressbar( {
2012-05-26 03:10:46 +00:00
change: function() {
changes++;
2016-04-06 13:08:28 +00:00
assert.equal( element.progressbar( "value" ), value, "change at " + value );
2012-05-26 03:10:46 +00:00
},
complete: function() {
2016-04-06 13:08:28 +00:00
assert.equal( changes, 3, "complete triggered after change and not on indeterminate" );
assert.equal( element.progressbar( "value" ), 100, "value is 100" );
2012-05-26 03:10:46 +00:00
}
2015-08-24 12:58:48 +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 );
2015-08-24 12:58:48 +00:00
} );
} );