aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/slider
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-07-17 15:04:16 -0400
committerScott González <scott.gonzalez@gmail.com>2012-07-17 15:04:16 -0400
commit174df61a6e9f50286f595b3fb6af4bd0a6450392 (patch)
tree6984433e46ec0aa21e03798e432f25729d779e7a /tests/unit/slider
parentf7b32d9a8fec3967b1bb5aafa9cda88cd83cc294 (diff)
downloadjquery-ui-174df61a6e9f50286f595b3fb6af4bd0a6450392.tar.gz
jquery-ui-174df61a6e9f50286f595b3fb6af4bd0a6450392.zip
Slider tests: Minor cleanup: added expect() calls, fixed left-over slider that was appended to body.
Diffstat (limited to 'tests/unit/slider')
-rw-r--r--tests/unit/slider/slider_core.js8
-rw-r--r--tests/unit/slider/slider_events.js6
-rw-r--r--tests/unit/slider/slider_methods.js19
-rw-r--r--tests/unit/slider/slider_options.js6
4 files changed, 22 insertions, 17 deletions
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $('<div></div>');
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 = $( "<div></div>" )
- .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 = $( "<div></div>" )
- .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() {
- $("<div></div>").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');
-
- $('<div></div>').appendTo('body').remove().slider().slider("destroy").remove();
- ok(true, '.slider("destroy") called on disconnected DOMElement');
-
- var expected = $('<div></div>').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 = $('<div></div>').slider(),
actual = expected.slider('enable');
@@ -56,6 +49,7 @@ test("enable", function() {
});
test("disable", function() {
+ expect( 5 );
var el,
expected = $('<div></div>').slider(),
actual = expected.slider('disable');
@@ -70,6 +64,7 @@ test("disable", function() {
});
test("value", function() {
+ expect( 17 );
$([false, 'min', 'max']).each(function() {
var el = $('<div></div>').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 = $('<div></div>');
options = {
@@ -30,6 +31,7 @@ test("max", function() {
});
test("min", function() {
+ expect( 2 );
el = $('<div></div>');
options = {
@@ -48,6 +50,7 @@ test("min", function() {
});
test("orientation", function() {
+ expect( 6 );
el = $('<div></div>');
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 = $('<div></div>').slider({
min: 0,
value: 0,
@@ -112,7 +116,7 @@ test("step", function() {
el.slider("value", 19);
equal( el.slider("value"), 20 );
-el = $('<div></div>').slider({
+ el = $('<div></div>').slider({
min: 0,
value: 0,
step: 20,