diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-05-25 23:10:46 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-05-25 23:10:46 -0400 |
commit | a738d7372eb65c726ab31f32b7561975ca604edb (patch) | |
tree | 7b5de8da6edf0db26a40cd22a5b00cc18aeb80a0 /tests | |
parent | e986f36871dc085774b40d20bd0ca5b91912f682 (diff) | |
download | jquery-ui-a738d7372eb65c726ab31f32b7561975ca604edb.tar.gz jquery-ui-a738d7372eb65c726ab31f32b7561975ca604edb.zip |
Progressbar tests: Cleanup.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/progressbar/progressbar_core.js | 36 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_events.js | 56 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_methods.js | 43 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_options.js | 52 |
4 files changed, 75 insertions, 112 deletions
diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index a0ea6c48f..0a2ef895b 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -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); diff --git a/tests/unit/progressbar/progressbar_events.js b/tests/unit/progressbar/progressbar_events.js index f3713171b..bb0d3ca5c 100644 --- a/tests/unit/progressbar/progressbar_events.js +++ b/tests/unit/progressbar/progressbar_events.js @@ -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); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js index 966c0c55a..89478b9b1 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/progressbar_methods.js @@ -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); diff --git a/tests/unit/progressbar/progressbar_options.js b/tests/unit/progressbar/progressbar_options.js index 815606ec6..f050fc5da 100644 --- a/tests/unit/progressbar/progressbar_options.js +++ b/tests/unit/progressbar/progressbar_options.js @@ -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); |