Skip to content

Commit 174df61

Browse files
committed
Slider tests: Minor cleanup: added expect() calls, fixed left-over slider that was appended to body.
1 parent f7b32d9 commit 174df61

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

tests/unit/slider/slider_core.js

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function handle() {
1616
module("slider: core");
1717

1818
test("keydown HOME on handle sets value to min", function() {
19+
expect( 2 );
1920
el = $('<div></div>');
2021
options = {
2122
max: 5,
@@ -50,6 +51,7 @@ test("keydown HOME on handle sets value to min", function() {
5051
});
5152

5253
test("keydown END on handle sets value to max", function() {
54+
expect( 2 );
5355
el = $('<div></div>');
5456
options = {
5557
max: 5,
@@ -84,6 +86,7 @@ test("keydown END on handle sets value to max", function() {
8486
});
8587

8688
test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than max", function() {
89+
expect( 4 );
8790
$.each(['horizontal', 'vertical'], function(i, orientation) {
8891
el = $('<div></div>');
8992
options = {
@@ -107,6 +110,7 @@ test("keydown PAGE_UP on handle increases value by 1/5 range, not greater than m
107110
});
108111

109112
test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than min", function() {
113+
expect( 4 );
110114
$.each(['horizontal', 'vertical'], function(i, orientation) {
111115
el = $('<div></div>');
112116
options = {
@@ -130,6 +134,7 @@ test("keydown PAGE_DOWN on handle decreases value by 1/5 range, not less than mi
130134
});
131135

132136
test("keydown UP on handle increases value by step, not greater than max", function() {
137+
expect( 4 );
133138
el = $('<div></div>');
134139
options = {
135140
max: 5,
@@ -170,6 +175,7 @@ test("keydown UP on handle increases value by step, not greater than max", funct
170175
});
171176

172177
test("keydown RIGHT on handle increases value by step, not greater than max", function() {
178+
expect( 4 );
173179
el = $('<div></div>');
174180
options = {
175181
max: 5,
@@ -210,6 +216,7 @@ test("keydown RIGHT on handle increases value by step, not greater than max", fu
210216
});
211217

212218
test("keydown DOWN on handle decreases value by step, not less than min", function() {
219+
expect( 4 );
213220
el = $('<div></div>');
214221
options = {
215222
max: 5,
@@ -250,6 +257,7 @@ test("keydown DOWN on handle decreases value by step, not less than min", functi
250257
});
251258

252259
test("keydown LEFT on handle decreases value by step, not less than min", function() {
260+
expect( 4 );
253261
el = $('<div></div>');
254262
options = {
255263
max: 5,

tests/unit/slider/slider_events.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ module( "slider: events" );
1212
test( "mouse based interaction", function() {
1313
expect(4);
1414

15-
var el = $( "<div></div>" )
16-
.appendTo( "body" )
15+
var el = $( "#slider1" )
1716
.slider({
1817
start: function(event, ui) {
1918
equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
@@ -37,8 +36,7 @@ test( "keyboard based interaction", function() {
3736
expect(3);
3837

3938
// Test keyup at end of handle slide (keyboard)
40-
var el = $( "<div></div>" )
41-
.appendTo( "body" )
39+
var el = $( "#slider1" )
4240
.slider({
4341
start: function(event, ui) {
4442
equal( event.originalEvent.type, "keydown", "start triggered by keydown" );

tests/unit/slider/slider_methods.js

+7-12
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,14 @@ test("init", function() {
2727
});
2828

2929
test("destroy", function() {
30-
$("<div></div>").appendTo('body').slider().slider("destroy").remove();
31-
ok(true, '.slider("destroy") called on element');
32-
33-
$([]).slider().slider("destroy").remove();
34-
ok(true, '.slider("destroy") called on empty collection');
35-
36-
$('<div></div>').appendTo('body').remove().slider().slider("destroy").remove();
37-
ok(true, '.slider("destroy") called on disconnected DOMElement');
38-
39-
var expected = $('<div></div>').slider(),
40-
actual = expected.slider('destroy');
41-
equal(actual, expected, 'destroy is chainable');
30+
expect( 1 );
31+
domEqual( "#slider1", function() {
32+
$( "#slider1" ).slider().slider( "destroy" );
33+
});
4234
});
4335

4436
test("enable", function() {
37+
expect( 5 );
4538
var el,
4639
expected = $('<div></div>').slider(),
4740
actual = expected.slider('enable');
@@ -56,6 +49,7 @@ test("enable", function() {
5649
});
5750

5851
test("disable", function() {
52+
expect( 5 );
5953
var el,
6054
expected = $('<div></div>').slider(),
6155
actual = expected.slider('disable');
@@ -70,6 +64,7 @@ test("disable", function() {
7064
});
7165

7266
test("value", function() {
67+
expect( 17 );
7368
$([false, 'min', 'max']).each(function() {
7469
var el = $('<div></div>').slider({
7570
range: this,

tests/unit/slider/slider_options.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function handle() {
1212
module("slider: options");
1313

1414
test("max", function() {
15+
expect( 2 );
1516
el = $('<div></div>');
1617

1718
options = {
@@ -30,6 +31,7 @@ test("max", function() {
3031
});
3132

3233
test("min", function() {
34+
expect( 2 );
3335
el = $('<div></div>');
3436

3537
options = {
@@ -48,6 +50,7 @@ test("min", function() {
4850
});
4951

5052
test("orientation", function() {
53+
expect( 6 );
5154
el = $('<div></div>');
5255

5356
options = {
@@ -92,6 +95,7 @@ test("orientation", function() {
9295
// value option/method: the value option is not restricted by min/max/step.
9396
// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple)
9497
test("step", function() {
98+
expect( 9 );
9599
var el = $('<div></div>').slider({
96100
min: 0,
97101
value: 0,
@@ -112,7 +116,7 @@ test("step", function() {
112116
el.slider("value", 19);
113117
equal( el.slider("value"), 20 );
114118

115-
el = $('<div></div>').slider({
119+
el = $('<div></div>').slider({
116120
min: 0,
117121
value: 0,
118122
step: 20,

0 commit comments

Comments
 (0)