Index: slider/slider_core.js =================================================================== --- slider/slider_core.js (revision 3093) +++ slider/slider_core.js (working copy) @@ -243,4 +243,108 @@ el.slider("destroy"); }); +test("ARIA Min and Max", function() { + el = $('
'); + + options = { + max: 54, + min: 3, + orientation: 'horizontal', + value:15 + }; + + el.slider(options); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 54, "The ARIA-valuemax should be 54" ); + equals(handles.attr("aria-valuemin"), 3, "The ARIA-valuemin should be 3" ); + equals(handles.attr("aria-valuenow"), 15, "The ARIA-valuenow should be 15" ); + el.slider('destroy'); +}); + +test("ARIA Min and Max with default options", function() { + el = $('
'); + + el.slider(); + var handles = handle(); + + equals(handles.attr("aria-valuemax"), 100, "The ARIA max should be 100" ); + equals(handles.attr("aria-valuemin"), 0, "The ARIA min should be 0" ); + equals(handles.attr("aria-valuenow"), 0, "The ARIA-valuenow should be 0" ); + el.slider('destroy'); +}); + +test("ARIA-valuenow after keydown LEFT", function(){ + el = $('
'); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 4 + }; + el.slider(options); + var handles = handle(); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(handles.attr("aria-valuenow"), 3, "The ARIA-valuenow should be 3" ); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(handles.attr("aria-valuenow"), 2, "The ARIA-valuenow should be 2" ); + + el.slider("destroy"); + +}); + +test("ARIA-valuenow after keydown RIGHT", function(){ + el = $('
'); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 2 + }; + el.slider(options); + var handles = handle(); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 3, "The ARIA-valuenow should be 3" ); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 4, "The ARIA-valuenow should be 4" ); + + el.slider("destroy"); + +}); + +test("ARIA-valuenow after keydown RIGHT", function(){ + el = $('
'); + options = { + max: 5, + min: -5, + orientation: 'horizontal', + step: 1, + value: 2 + }; + el.slider(options); + var handles = handle(); + + el.slider(options.value, options.min + options.step); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 3, "The ARIA-valuenow should be 3" ); + + handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(handles.attr("aria-valuenow"), 4, "The ARIA-valuenow should be 4" ); + + el.slider("destroy"); + +}); + + })(jQuery); Index: slider/slider_options.js =================================================================== --- slider/slider_options.js (revision 3093) +++ slider/slider_options.js (working copy) @@ -87,7 +87,22 @@ }); test("range", function() { - ok(false, "missing test - untested code is broken code."); + el = $('
'); + + options = { + max: 100, + min: 0, + orientation: 'horizontal', + values: [10,50], + range:true + }; + + el.slider(options); + var handles = handle(); + ok(el.slider("option", "range") == options.range); + equals((options.values.length), 2, "range is set to true, length of values is"); + el.slider('destroy'); + }); test("step", function() { @@ -95,11 +110,50 @@ }); test("value", function() { - ok(false, "missing test - untested code is broken code."); + el = $('
'); + + options = { + max: 100, + min: 0, + orientation: 'horizontal', + value: 5 + }; + + el.slider(options); + var handles = handle(); + ok(el.slider("option", "value") == options.value); + equals(handles.attr("aria-valuenow"), 5, "the aria-valuenow is"); + el.slider('destroy'); }); test("values", function() { - ok(false, "missing test - untested code is broken code."); + el = $('
'); + + options = { + max: 100, + min: 0, + orientation: 'horizontal', + step: 1, + values: [10,50], + range: true + }; + + el.slider(options, options.step); + var handles = handle(); + var firstHandle = handles.eq(0); + equals(firstHandle.attr("aria-valuenow"), 10, "The aria-valuenow of the first handle is"); + var secondHandle = handles.eq(1); + equals(secondHandle.attr("aria-valuenow"), 50, "The aria-valuenow of the second handle is"); + firstHandle.simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(firstHandle.attr("aria-valuenow"), 11, "The aria-valuenow of the first handle after keydown RIGHT is" ); + firstHandle.simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(firstHandle.attr("aria-valuenow"), 10, "The aria-valuenow of the first handle after keydown LEFT is" ); + secondHandle.simulate("keydown", { keyCode: $.ui.keyCode.LEFT }); + equals(secondHandle.attr("aria-valuenow"), 49, "The aria-valuenow of the second handle after keydown LEFT is"); + secondHandle.simulate("keydown", { keyCode: $.ui.keyCode.RIGHT }); + equals(secondHandle.attr("aria-valuenow"), 50, "The aria-valuenow of the second handle after keydown RIGHT is"); + + el.slider('destroy'); }); })(jQuery);