Skip to content
Permalink
Browse files

Progressbar tests: Cleanup.

  • Loading branch information...
scottgonzalez committed May 26, 2012
1 parent e986f36 commit a738d7372eb65c726ab31f32b7561975ca604edb
@@ -1,28 +1,20 @@
/*
* progressbar_core.js
*/
module( "progressbar: core" );

var el;
test( "accessibility", function() {
expect( 7 );
var element = $( "#progressbar" ).progressbar();

(function($) {
equal( element.attr( "role" ), "progressbar", "aria role" );
equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" );
equal( element.attr( "aria-valuemax" ), 100, "aria-valuemax" );
equal( element.attr( "aria-valuenow" ), 0, "aria-valuenow initially" );

module("progressbar: core");
element.progressbar( "value", 77 );
equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" );

test("accessibility", function() {
expect(7);
el = $("#progressbar").progressbar();
element.progressbar( "disable" );
equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" );

equal(el.attr("role"), "progressbar", "aria role");
equal(el.attr("aria-valuemin"), 0, "aria-valuemin");
equal(el.attr("aria-valuemax"), 100, "aria-valuemax");
equal(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
el.progressbar("value", 77);
equal(el.attr("aria-valuenow"), 77, "aria-valuenow");
el.progressbar("disable");
equal(el.attr("aria-disabled"), "true", "aria-disabled on");
el.progressbar("enable");
// FAIL: for some reason IE6 and 7 return a boolean false instead of the string
equal(el.attr("aria-disabled"), "false", "aria-disabled off");
element.progressbar( "enable" );
equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" );
});

})(jQuery);
@@ -1,51 +1,43 @@
/*
* progressbar_events.js
*/
(function($) {
module( "progressbar: events" );

module("progressbar: events");

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

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

test( "complete", function() {
expect( 3 );
var changes = 0,
value;

$( "#progressbar" ).progressbar({
change: function() {
changes++;
deepEqual( $( this ).progressbar( "value" ), value, "change at " + value );
},
complete: function() {
equal( changes, 2, "complete triggered after change" );
}
});
var value,
changes = 0,
element = $( "#progressbar" ).progressbar({
change: function() {
changes++;
deepEqual( element.progressbar( "value" ), value, "change at " + value );
},
complete: function() {
equal( changes, 2, "complete triggered after change" );
}
});

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

})(jQuery);
@@ -1,36 +1,17 @@
/*
* progressbar_methods.js
*/
(function($) {
module( "progressbar: methods" );

module("progressbar: methods");

test("init", function() {
expect(1);

$("<div></div>").appendTo('body').progressbar().remove();
ok(true, '.progressbar() called on element');

});

test("destroy", function() {
expect(2);

$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove();
ok(true, '.progressbar("destroy") called on element');

var expected = $('<div></div>').progressbar(),
actual = expected.progressbar('destroy');
equal(actual, expected, 'destroy is chainable');
test( "destroy", function() {
expect( 1 );
domEqual( "#progressbar", function() {
$( "#progressbar" ).progressbar().progressbar( "destroy" );
});
});

test('value', function() {
expect(3);
test( "value", function() {
expect( 3 );

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

})(jQuery);
@@ -1,13 +1,8 @@
/*
* progressbar_options.js
*/
(function($) {
module( "progressbar: options" );

module("progressbar: options");

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

// Ticket #7231 - valueDiv should be hidden when value is at 0%
@@ -16,44 +11,47 @@ test( "value: visibility of valueDiv", function() {
var element = $( "#progressbar" ).progressbar({
value: 0
});
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value is initialized at 0" );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value is initialized at 0" );
element.progressbar( "value", 1 );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ), "valueDiv visible when value is set to 1" );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
"valueDiv visible when value is set to 1" );
element.progressbar( "value", 100 );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ), "valueDiv visible when value is set to 100" );
ok( element.children( ".ui-progressbar-value" ).is( ":visible" ),
"valueDiv visible when value is set to 100" );
element.progressbar( "value", 0 );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ), "valueDiv hidden when value is set to 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)" );
ok( element.children( ".ui-progressbar-value" ).is( ":hidden" ),
"valueDiv hidden when value set to -1 (normalizes to 0)" );
});

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

test("{ value : -5 }", function() {
$("#progressbar").progressbar({
test( "{ value : -5 }", function() {
$( "#progressbar" ).progressbar({
value: -5
});
deepEqual( 0, $("#progressbar").progressbar("value") );
deepEqual( 0, $( "#progressbar" ).progressbar( "value" ) );
});

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

test("{ max : 5, value : 10 }", function() {
test( "{ max : 5, value : 10 }", function() {
$("#progressbar").progressbar({
max: 5,
value: 10
});
deepEqual( 5, $("#progressbar").progressbar("value") );
deepEqual( 5, $( "#progressbar" ).progressbar( "value" ) );
});

})(jQuery);

0 comments on commit a738d73

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