Slider tests: Minor cleanup: added expect() calls, fixed left-over slider that was appended to body.

This commit is contained in:
Scott González 2012-07-17 15:04:16 -04:00
parent f7b32d9a8f
commit 174df61a6e
4 changed files with 22 additions and 17 deletions

View File

@ -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,

View File

@ -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" );

View File

@ -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,

View File

@ -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,