diff options
author | Filipp Lepalaan <f@230.to> | 2014-02-19 18:02:09 +0200 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2014-02-19 18:02:09 +0200 |
commit | 75ad7e4bd7d69243e7e5281c2642f00478fb072d (patch) | |
tree | eaaaf360902d369f42d94778aac8803db7973ce0 /apps/it/static/js/ui/tests/unit/progressbar | |
parent | cfc7c3f52544af8a71d3fa3988a06fee200d2c24 (diff) | |
download | pudding-75ad7e4bd7d69243e7e5281c2642f00478fb072d.tar.gz pudding-75ad7e4bd7d69243e7e5281c2642f00478fb072d.tar.bz2 pudding-75ad7e4bd7d69243e7e5281c2642f00478fb072d.zip |
Added tags, jquery UI
Diffstat (limited to 'apps/it/static/js/ui/tests/unit/progressbar')
7 files changed, 287 insertions, 0 deletions
diff --git a/apps/it/static/js/ui/tests/unit/progressbar/all.html b/apps/it/static/js/ui/tests/unit/progressbar/all.html new file mode 100644 index 0000000..ed17c36 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/all.html @@ -0,0 +1,30 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Progressbar Test Suite</title> + + <script src="../../../jquery-1.10.2.js"></script> + + <link rel="stylesheet" href="../../../external/qunit.css"> + <link rel="stylesheet" href="../qunit-composite.css"> + <script src="../../../external/qunit.js"></script> + <script src="../qunit-composite.js"></script> + <script src="../subsuite.js"></script> + + <script> + testAllVersions( "progressbar" ); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Progressbar Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar.html b/apps/it/static/js/ui/tests/unit/progressbar/progressbar.html new file mode 100644 index 0000000..70a4abe --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar.html @@ -0,0 +1,44 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Progressbar Test Suite</title> + + <script src="../../jquery.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> + <script> + TestHelpers.loadResources({ + css: [ "ui.core", "ui.progressbar" ], + js: [ + "ui/jquery.ui.core.js", + "ui/jquery.ui.widget.js", + "ui/jquery.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> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Progressbar Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +<div id="progressbar"></div> + +</div> +</body> +</html> diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar_common.js b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_common.js new file mode 100644 index 0000000..0768576 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_common.js @@ -0,0 +1,12 @@ +TestHelpers.commonWidgetTests( "progressbar", { + defaults: { + disabled: false, + max: 100, + value: 0, + + //callbacks + change: null, + complete: null, + create: null + } +}); diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar_core.js b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_core.js new file mode 100644 index 0000000..8f4a138 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_core.js @@ -0,0 +1,53 @@ +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" ); +}); diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar_events.js b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_events.js new file mode 100644 index 0000000..95effda --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_events.js @@ -0,0 +1,51 @@ +module( "progressbar: events" ); + +test( "create", function() { + expect( 1 ); + $( "#progressbar" ).progressbar({ + value: 5, + create: function() { + equal( $( this ).progressbar( "value" ), 5, "Correct value at create" ); + }, + change: function() { + ok( false, "create has triggered change()" ); + } + }); +}); + +test( "change", function() { + 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() { + expect( 5 ); + var value, + changes = 0, + element = $( "#progressbar" ).progressbar({ + change: function() { + changes++; + equal( element.progressbar( "value" ), value, "change at " + value ); + }, + complete: function() { + equal( changes, 3, "complete triggered after change and not on indeterminate" ); + equal( element.progressbar( "value" ), 100, "value is 100" ); + } + }); + + value = 5; + element.progressbar( "value", value ); + value = false; + element.progressbar( "value", value ); + value = 100; + element.progressbar( "value", value ); +}); diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar_methods.js b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_methods.js new file mode 100644 index 0000000..cf7faf6 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_methods.js @@ -0,0 +1,25 @@ +module( "progressbar: methods" ); + +test( "destroy", function() { + expect( 1 ); + domEqual( "#progressbar", function() { + $( "#progressbar" ).progressbar().progressbar( "destroy" ); + }); +}); + +test( "value", function() { + expect( 3 ); + + var element = $( "<div>" ).progressbar({ value: 20 }); + equal( element.progressbar( "value" ), 20, "correct value as getter" ); + strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" ); + equal( element.progressbar( "option", "value" ), 30, "correct value after setter" ); +}); + +test( "widget", function() { + expect( 2 ); + var element = $( "#progressbar" ).progressbar(), + widgetElement = element.progressbar( "widget" ); + equal( widgetElement.length, 1, "one element" ); + strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); +}); diff --git a/apps/it/static/js/ui/tests/unit/progressbar/progressbar_options.js b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_options.js new file mode 100644 index 0000000..bc0b5d0 --- /dev/null +++ b/apps/it/static/js/ui/tests/unit/progressbar/progressbar_options.js @@ -0,0 +1,72 @@ +module( "progressbar: options" ); + +test( "{ value: 0 }, default", function() { + expect( 1 ); + $( "#progressbar" ).progressbar(); + equal( $( "#progressbar" ).progressbar( "value" ), 0 ); +}); + +// Ticket #7231 - valueDiv should be hidden when value is at 0% +test( "value: visibility of valueDiv", function() { + expect( 4 ); + var element = $( "#progressbar" ).progressbar({ + value: 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" ); + element.progressbar( "value", 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" ); +}); + +test( "{ value: 5 }", function() { + expect( 1 ); + $( "#progressbar" ).progressbar({ + value: 5 + }); + equal( $( "#progressbar" ).progressbar( "value" ), 5 ); +}); + +test( "{ value: -5 }", function() { + expect( 1 ); + $( "#progressbar" ).progressbar({ + value: -5 + }); + equal( $( "#progressbar" ).progressbar( "value" ), 0, + "value constrained at min" ); +}); + +test( "{ value: 105 }", function() { + expect( 1 ); + $( "#progressbar" ).progressbar({ + value: 105 + }); + equal( $( "#progressbar" ).progressbar( "value" ), 100, + "value constrained at max" ); +}); + +test( "{ value: 10, max: 5 }", function() { + expect( 1 ); + $("#progressbar").progressbar({ + max: 5, + value: 10 + }); + equal( $( "#progressbar" ).progressbar( "value" ), 5, + "value constrained at max" ); +}); + +test( "change max below value", function() { + expect( 1 ); + $("#progressbar").progressbar({ + max: 10, + value: 10 + }).progressbar( "option", "max", 5 ); + equal( $( "#progressbar" ).progressbar( "value" ), 5, + "value constrained at max" ); +}); |