diff options
Diffstat (limited to 'tests/unit/progressbar')
-rw-r--r-- | tests/unit/progressbar/all.html | 4 | ||||
-rw-r--r-- | tests/unit/progressbar/common.js | 24 | ||||
-rw-r--r-- | tests/unit/progressbar/core.js | 64 | ||||
-rw-r--r-- | tests/unit/progressbar/events.js (renamed from tests/unit/progressbar/progressbar_events.js) | 7 | ||||
-rw-r--r-- | tests/unit/progressbar/methods.js (renamed from tests/unit/progressbar/progressbar_methods.js) | 17 | ||||
-rw-r--r-- | tests/unit/progressbar/options.js (renamed from tests/unit/progressbar/progressbar_options.js) | 7 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar.html | 26 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_common.js | 12 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_core.js | 53 |
9 files changed, 119 insertions, 95 deletions
diff --git a/tests/unit/progressbar/all.html b/tests/unit/progressbar/all.html index c8cfc824d..b20bdd27e 100644 --- a/tests/unit/progressbar/all.html +++ b/tests/unit/progressbar/all.html @@ -7,9 +7,9 @@ <script src="../../../external/jquery/jquery.js"></script> <link rel="stylesheet" href="../../../external/qunit/qunit.css"> - <link rel="stylesheet" href="../qunit-composite.css"> + <link rel="stylesheet" href="../../../external/qunit-composite/qunit-composite.css"> <script src="../../../external/qunit/qunit.js"></script> - <script src="../qunit-composite.js"></script> + <script src="../../../external/qunit-composite/qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/progressbar/common.js b/tests/unit/progressbar/common.js new file mode 100644 index 000000000..c949f136f --- /dev/null +++ b/tests/unit/progressbar/common.js @@ -0,0 +1,24 @@ +define( [ + "lib/common", + "ui/progressbar" +], function( common ) { + +common.testWidget( "progressbar", { + defaults: { + classes: { + "ui-progressbar": "ui-corner-all", + "ui-progressbar-value": "ui-corner-left", + "ui-progressbar-complete": "ui-corner-right" + }, + disabled: false, + max: 100, + value: 0, + + //callbacks + change: null, + complete: null, + create: null + } +}); + +} ); diff --git a/tests/unit/progressbar/core.js b/tests/unit/progressbar/core.js new file mode 100644 index 000000000..05eea9ef7 --- /dev/null +++ b/tests/unit/progressbar/core.js @@ -0,0 +1,64 @@ +define( [ + "jquery", + "ui/progressbar" +], function( $ ) { + +module( "progressbar: core" ); + +test( "markup structure", function( assert ) { + expect( 7 ); + var element = $( "#progressbar" ).progressbar(), + value = element.children().eq( 0 ); + + assert.hasClasses( element, "ui-progressbar ui-widget ui-widget-content" ); + assert.hasClasses( value, "ui-progressbar-value ui-widget-header" ); + assert.lacksClasses( value, "ui-progressbar-complete" ); + assert.lacksClasses( element, "ui-progressbar-indeterminate" ); + equal( element.children().length, 1, "Main element contains one child" ); + + element.progressbar( "option", "value", 100 ); + assert.hasClasses( value, "ui-progressbar-complete ui-widget-header ui-progressbar-value" ); + equal( element.children().children().length, 0, "no overlay div" ); +}); + +test( "markup structure - indeterminate", function( assert ) { + expect( 5 ); + var element = $( "#progressbar" ).progressbar({ value: false }), + children = element.children(); + + assert.hasClasses( element, "ui-progressbar ui-progressbar-indeterminate ui-widget ui-widget-content" ); + assert.hasClasses( children[ 0 ], "ui-progressbar-value ui-widget-header" ); + equal( children.length, 1, "Main element contains one child" ); + assert.hasClasses( children[ 0 ], "ui-progressbar-value" ); + equal( children.children( ".ui-progressbar-overlay" ).length, 1, + "Value has class ui-progressbar-overlay" ); +}); + +test( "accessibility", function() { + expect( 11 ); + var element = $( "#progressbar" ).progressbar(); + + 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" ); + + element.progressbar( "value", 77 ); + equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" ); + + element.progressbar( "option", "max", 150 ); + equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); + + element.progressbar( "disable" ); + equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" ); + + element.progressbar( "enable" ); + equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" ); + + element.progressbar( "option", "value", false ); + equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" ); + equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); + equal( element.attr( "aria-valuenow" ), null, "aria-valuenow" ); +}); + +} ); diff --git a/tests/unit/progressbar/progressbar_events.js b/tests/unit/progressbar/events.js index 95effda75..a40b2c432 100644 --- a/tests/unit/progressbar/progressbar_events.js +++ b/tests/unit/progressbar/events.js @@ -1,3 +1,8 @@ +define( [ + "jquery", + "ui/progressbar" +], function( $ ) { + module( "progressbar: events" ); test( "create", function() { @@ -49,3 +54,5 @@ test( "complete", function() { value = 100; element.progressbar( "value", value ); }); + +} ); diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/methods.js index 004eacf90..eaf0a5c76 100644 --- a/tests/unit/progressbar/progressbar_methods.js +++ b/tests/unit/progressbar/methods.js @@ -1,20 +1,25 @@ +define( [ + "jquery", + "ui/progressbar" +], function( $ ) { + module( "progressbar: methods" ); -test( "destroy", function() { +test( "destroy", function( assert ) { expect( 1 ); - domEqual( "#progressbar", function() { + assert.domEqual( "#progressbar", function() { $( "#progressbar" ).progressbar().progressbar( "destroy" ); }); }); -test( "disable", function() { +test( "disable", function( assert ) { expect( 3 ); var element = $( "#progressbar" ).progressbar().progressbar( "disable" ); - ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" ); + assert.hasClasses( element.progressbar( "widget" ), "ui-state-disabled" ); ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" ); - ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" ); + assert.hasClasses( element.progressbar( "widget" ), "ui-progressbar-disabled" ); }); test( "value", function() { @@ -33,3 +38,5 @@ test( "widget", function() { equal( widgetElement.length, 1, "one element" ); strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); }); + +} ); diff --git a/tests/unit/progressbar/progressbar_options.js b/tests/unit/progressbar/options.js index bc0b5d00d..7b6ac9db2 100644 --- a/tests/unit/progressbar/progressbar_options.js +++ b/tests/unit/progressbar/options.js @@ -1,3 +1,8 @@ +define( [ + "jquery", + "ui/progressbar" +], function( $ ) { + module( "progressbar: options" ); test( "{ value: 0 }, default", function() { @@ -70,3 +75,5 @@ test( "change max below value", function() { equal( $( "#progressbar" ).progressbar( "value" ), 5, "value constrained at max" ); }); + +} ); diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index 56a02bcd4..18a5195bc 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -4,29 +4,9 @@ <meta charset="utf-8"> <title>jQuery UI Progressbar Test Suite</title> - <script src="../../jquery.js"></script> - <link rel="stylesheet" href="../../../external/qunit/qunit.css"> - <script src="../../../external/qunit/qunit.js"></script> - <script src="../../../external/jquery-simulate/jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script> - TestHelpers.loadResources({ - css: [ "core", "progressbar" ], - js: [ - "ui/core.js", - "ui/widget.js", - "ui/progressbar.js" - ] - }); - </script> - - <script src="progressbar_common.js"></script> - <script src="progressbar_core.js"></script> - <script src="progressbar_events.js"></script> - <script src="progressbar_methods.js"></script> - <script src="progressbar_options.js"></script> - - <script src="../swarminject.js"></script> + <script src="../../../external/requirejs/require.js"></script> + <script src="../../lib/css.js" data-modules="core progressbar"></script> + <script src="../../lib/bootstrap.js" data-widget="progressbar"></script> </head> <body> diff --git a/tests/unit/progressbar/progressbar_common.js b/tests/unit/progressbar/progressbar_common.js deleted file mode 100644 index 0768576f5..000000000 --- a/tests/unit/progressbar/progressbar_common.js +++ /dev/null @@ -1,12 +0,0 @@ -TestHelpers.commonWidgetTests( "progressbar", { - defaults: { - disabled: false, - max: 100, - value: 0, - - //callbacks - change: null, - complete: null, - create: null - } -}); diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js deleted file mode 100644 index 8f4a138ce..000000000 --- a/tests/unit/progressbar/progressbar_core.js +++ /dev/null @@ -1,53 +0,0 @@ -module( "progressbar: core" ); - -test( "markup structure", function() { - expect( 5 ); - var element = $( "#progressbar" ).progressbar(); - ok( element.hasClass( "ui-progressbar" ), "main element is .ui-progressbar" ); - ok( !element.hasClass( "ui-progressbar-indeterminate" ), - "main element is not .ui-progressbar-indeterminate" ); - equal( element.children().length, 1, "main element contains one child" ); - ok( element.children().eq( 0 ).hasClass( "ui-progressbar-value" ), - "child is .ui-progressbar-value" ); - equal( element.children().children().length, 0, "no overlay div" ); -}); - -test( "markup structure - indeterminate", function() { - expect( 5 ); - var element = $( "#progressbar" ).progressbar({ value: false }); - ok( element.hasClass( "ui-progressbar" ), "main element is .ui-progressbar" ); - ok( element.hasClass( "ui-progressbar-indeterminate" ), - "main element is .ui-progressbar-indeterminate" ); - equal( element.children().length, 1, "main element contains one child" ); - ok( element.children().eq( 0 ).hasClass( "ui-progressbar-value" ), - "child is .ui-progressbar-value" ); - equal( element.children().children( ".ui-progressbar-overlay" ).length, 1, - ".ui-progressbar-value has .ui-progressbar-overlay" ); -}); - -test( "accessibility", function() { - expect( 11 ); - var element = $( "#progressbar" ).progressbar(); - - 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" ); - - element.progressbar( "value", 77 ); - equal( element.attr( "aria-valuenow" ), 77, "aria-valuenow" ); - - element.progressbar( "option", "max", 150 ); - equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); - - element.progressbar( "disable" ); - equal( element.attr( "aria-disabled" ), "true", "aria-disabled on" ); - - element.progressbar( "enable" ); - equal( element.attr( "aria-disabled" ), "false", "aria-disabled off" ); - - element.progressbar( "option", "value", false ); - equal( element.attr( "aria-valuemin" ), 0, "aria-valuemin" ); - equal( element.attr( "aria-valuemax" ), 150, "aria-valuemax" ); - strictEqual( element.attr( "aria-valuenow" ), undefined, "aria-valuenow" ); -}); |