From 75ad7e4bd7d69243e7e5281c2642f00478fb072d Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 19 Feb 2014 18:02:09 +0200 Subject: Added tags, jquery UI --- .../static/js/ui/tests/unit/progressbar/all.html | 30 +++++++++ .../js/ui/tests/unit/progressbar/progressbar.html | 44 +++++++++++++ .../tests/unit/progressbar/progressbar_common.js | 12 ++++ .../ui/tests/unit/progressbar/progressbar_core.js | 53 ++++++++++++++++ .../tests/unit/progressbar/progressbar_events.js | 51 +++++++++++++++ .../tests/unit/progressbar/progressbar_methods.js | 25 ++++++++ .../tests/unit/progressbar/progressbar_options.js | 72 ++++++++++++++++++++++ 7 files changed, 287 insertions(+) create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/all.html create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar.html create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar_common.js create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar_core.js create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar_events.js create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar_methods.js create mode 100644 apps/it/static/js/ui/tests/unit/progressbar/progressbar_options.js (limited to 'apps/it/static/js/ui/tests/unit/progressbar') 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 @@ + + + + + jQuery UI Progressbar Test Suite + + + + + + + + + + + + + +

jQuery UI Progressbar Test Suite

+

+
+

+
    +
    + +
    + + 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 @@ + + + + + jQuery UI Progressbar Test Suite + + + + + + + + + + + + + + + + + + +

    jQuery UI Progressbar Test Suite

    +

    +
    +

    +
      +
      + +
      + +
      + + 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 = $( "
      " ).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" ); +}); -- cgit v1.2.3