From: Scott González Date: Tue, 17 Jul 2012 19:04:16 +0000 (-0400) Subject: Slider tests: Minor cleanup: added expect() calls, fixed left-over slider that was... X-Git-Tag: 1.9.0-rc.1~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=174df61a6e9f50286f595b3fb6af4bd0a6450392;p=jquery-ui.git Slider tests: Minor cleanup: added expect() calls, fixed left-over slider that was appended to body. --- diff --git a/tests/unit/slider/slider_core.js b/tests/unit/slider/slider_core.js index e5f21ee1b..86a516875 100644 --- a/tests/unit/slider/slider_core.js +++ b/tests/unit/slider/slider_core.js @@ -16,6 +16,7 @@ function handle() { module("slider: core"); test("keydown HOME on handle sets value to min", function() { + expect( 2 ); el = $('
'); options = { max: 5, @@ -50,6 +51,7 @@ test("keydown HOME on handle sets value to min", function() { }); test("keydown END on handle sets value to max", function() { + expect( 2 ); el = $('
'); options = { max: 5, @@ -84,6 +86,7 @@ test("keydown END on handle sets value to max", function() { }); test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() { + expect( 4 ); $.each(['horizontal', 'vertical'], function(i, orientation) { el = $('
'); options = { @@ -107,6 +110,7 @@ test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than m }); test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() { + expect( 4 ); $.each(['horizontal', 'vertical'], function(i, orientation) { el = $('
'); options = { @@ -130,6 +134,7 @@ test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than mi }); test("keydown UP on handle increases value by step, not greater than max", function() { + expect( 4 ); el = $('
'); options = { max: 5, @@ -170,6 +175,7 @@ test("keydown UP on handle increases value by step, not greater than max", funct }); test("keydown RIGHT on handle increases value by step, not greater than max", function() { + expect( 4 ); el = $('
'); options = { max: 5, @@ -210,6 +216,7 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu }); test("keydown DOWN on handle decreases value by step, not less than min", function() { + expect( 4 ); el = $('
'); options = { max: 5, @@ -250,6 +257,7 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi }); test("keydown LEFT on handle decreases value by step, not less than min", function() { + expect( 4 ); el = $('
'); options = { max: 5, diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js index 9e39d2a3e..4d0896442 100644 --- a/tests/unit/slider/slider_events.js +++ b/tests/unit/slider/slider_events.js @@ -12,8 +12,7 @@ module( "slider: events" ); test( "mouse based interaction", function() { expect(4); - var el = $( "
" ) - .appendTo( "body" ) + var el = $( "#slider1" ) .slider({ start: function(event, ui) { equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); @@ -37,8 +36,7 @@ test( "keyboard based interaction", function() { expect(3); // Test keyup at end of handle slide (keyboard) - var el = $( "
" ) - .appendTo( "body" ) + var el = $( "#slider1" ) .slider({ start: function(event, ui) { equal( event.originalEvent.type, "keydown", "start triggered by keydown" ); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index 79f80e868..1a6b493c9 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -27,21 +27,14 @@ test("init", function() { }); test("destroy", function() { - $("
").appendTo('body').slider().slider("destroy").remove(); - ok(true, '.slider("destroy") called on element'); - - $([]).slider().slider("destroy").remove(); - ok(true, '.slider("destroy") called on empty collection'); - - $('
').appendTo('body').remove().slider().slider("destroy").remove(); - ok(true, '.slider("destroy") called on disconnected DOMElement'); - - var expected = $('
').slider(), - actual = expected.slider('destroy'); - equal(actual, expected, 'destroy is chainable'); + expect( 1 ); + domEqual( "#slider1", function() { + $( "#slider1" ).slider().slider( "destroy" ); + }); }); test("enable", function() { + expect( 5 ); var el, expected = $('
').slider(), actual = expected.slider('enable'); @@ -56,6 +49,7 @@ test("enable", function() { }); test("disable", function() { + expect( 5 ); var el, expected = $('
').slider(), actual = expected.slider('disable'); @@ -70,6 +64,7 @@ test("disable", function() { }); test("value", function() { + expect( 17 ); $([false, 'min', 'max']).each(function() { var el = $('
').slider({ range: this, diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 09067a3e9..4d1983ec7 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -12,6 +12,7 @@ function handle() { module("slider: options"); test("max", function() { + expect( 2 ); el = $('
'); options = { @@ -30,6 +31,7 @@ test("max", function() { }); test("min", function() { + expect( 2 ); el = $('
'); options = { @@ -48,6 +50,7 @@ test("min", function() { }); test("orientation", function() { + expect( 6 ); el = $('
'); options = { @@ -92,6 +95,7 @@ test("orientation", function() { // value option/method: the value option is not restricted by min/max/step. // What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) test("step", function() { + expect( 9 ); var el = $('
').slider({ min: 0, value: 0, @@ -112,7 +116,7 @@ test("step", function() { el.slider("value", 19); equal( el.slider("value"), 20 ); -el = $('
').slider({ + el = $('
').slider({ min: 0, value: 0, step: 20,