aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2010-03-27 11:06:31 +0100
committerjzaefferer <joern.zaefferer@gmail.com>2010-03-27 11:06:31 +0100
commita009595bd3d7c6992d438900672fdf98f5e728c3 (patch)
tree6e9a6f074b639db9a92cd08f0be5f971356be453 /tests/unit
parentf1933142e485ceaaef9ef52e56abb9f43eaaad2d (diff)
parentc49be0be1a57cac325f021ffddc2f0fbccde1553 (diff)
downloadjquery-ui-a009595bd3d7c6992d438900672fdf98f5e728c3.tar.gz
jquery-ui-a009595bd3d7c6992d438900672fdf98f5e728c3.zip
Merge branch 'master' into tooltip
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/accordion/accordion.html67
-rw-r--r--tests/unit/accordion/accordion_methods.js18
-rw-r--r--tests/unit/accordion/accordion_options.js6
-rw-r--r--tests/unit/autocomplete/autocomplete_methods.js3
-rw-r--r--tests/unit/button/button_methods.js2
-rw-r--r--tests/unit/position/position.html4
-rw-r--r--tests/unit/position/position_core.js18
-rw-r--r--tests/unit/slider/slider_events.js58
-rw-r--r--tests/unit/slider/slider_options.js16
9 files changed, 108 insertions, 84 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index a7142250e..df0979803 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -25,8 +25,7 @@
<style>
#main { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; }
- #main h2 { margin: 0; }
- #main ul, #main li { padding: 0; }
+ #navigation * { margin: 0; padding: 0; font-size: 12px; }
</style>
</head>
<body>
@@ -39,37 +38,39 @@
<div id="main" style="position: absolute; top: -10000px; left: -10000px;">
- <div id="list1">
- <a>There is one obvious advantage:</a>
- <div>
- <p>
- You've seen it coming!
- <br/>
- Buy now and get nothing for free!
- <br/>
- Well, at least no free beer. Perhaps a bear, if you can afford it.
- </p>
- </div>
- <a>Now that you've got...</a>
- <div>
- <p>
- your bear, you have to admit it!
- <br/>
- No, we aren't selling bears.
- </p>
- <p>
- We could talk about renting one.
- </p>
- </div>
- <a>Rent one bear, ...</a>
- <div>
- <p>
- get two for three beer.
- </p>
- <p>
- And now, for something completely different.
- </p>
- </div>
+ <div>
+ <div id="list1" class="foo">
+ <a class="bar">There is one obvious advantage:</a>
+ <div style="" class="foo">
+ <p>
+ You've seen it coming!
+ <br/>
+ Buy now and get nothing for free!
+ <br/>
+ Well, at least no free beer. Perhaps a bear, if you can afford it.
+ </p>
+ </div>
+ <a class="bar">Now that you've got...</a>
+ <div style="" class="foo">
+ <p>
+ your bear, you have to admit it!
+ <br/>
+ No, we aren't selling bears.
+ </p>
+ <p>
+ We could talk about renting one.
+ </p>
+ </div>
+ <a class="bar">Rent one bear, ...</a>
+ <div style="" class="foo">
+ <p>
+ get two for three beer.
+ </p>
+ <p>
+ And now, for something completely different.
+ </p>
+ </div>
+ </div>
</div>
<div id="navigationWrapper">
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index 6761d24a6..d15a0b710 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -40,21 +40,9 @@ test("init", function() {
});
test("destroy", function() {
- $("<div></div>").appendTo('body').accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on element');
-
- $([]).accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on empty collection');
-
- $('<div></div>').accordion().accordion("destroy").remove();
- ok(true, '.accordion("destroy") called on disconnected DOMElement');
-
- $('<div></div>').accordion().accordion("destroy").accordion("foo").remove();
- ok(true, 'arbitrary method called after destroy');
-
- var expected = $('<div></div>').accordion(),
- actual = expected.accordion('destroy');
- equals(actual, expected, 'destroy is chainable');
+ var beforeHtml = $("#list1").parent().html();
+ var afterHtml = $("#list1").accordion().accordion("destroy").parent().html();
+ equal( afterHtml, beforeHtml );
});
test("enable", function() {
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 0782b4bb7..cc7fc0369 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -116,9 +116,9 @@ test("{ fillSpace: false }, default", function() {
test("{ fillSpace: true }", function() {
$("#navigationWrapper").height(500);
$('#navigation').accordion({ fillSpace: true });
- equals( $('#navigation > li:eq(0) > ul').height(), 362 );
- equals( $('#navigation > li:eq(1) > ul').height(), 362 );
- equals( $('#navigation > li:eq(2) > ul').height(), 362 );
+ equals( $('#navigation > li:eq(0) > ul').height(), 446 );
+ equals( $('#navigation > li:eq(1) > ul').height(), 446 );
+ equals( $('#navigation > li:eq(2) > ul').height(), 446 );
});
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js
index 5c20a6c95..76a600fe6 100644
--- a/tests/unit/autocomplete/autocomplete_methods.js
+++ b/tests/unit/autocomplete/autocomplete_methods.js
@@ -13,8 +13,7 @@ module("autocomplete: methods", {
test("destroy", function() {
var beforeHtml = $("#autocomplete").parent().html();
var afterHtml = $("#autocomplete").autocomplete().autocomplete("destroy").parent().html();
- // TODO can't use same, as that would insert the markup unescaped into the test results, screwing up other tests
- ok( beforeHtml == afterHtml );
+ equal( afterHtml, beforeHtml, "before/after html should be the same" );
})
var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"];
diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js
index 1fcd836b8..43c02d8cc 100644
--- a/tests/unit/button/button_methods.js
+++ b/tests/unit/button/button_methods.js
@@ -9,7 +9,7 @@ module("button: methods");
test("destroy", function() {
var beforeHtml = $("#button").parent().html();
var afterHtml = $("#button").button().button("destroy").parent().html();
- same( beforeHtml, afterHtml );
+ equal( afterHtml, beforeHtml );
});
})(jQuery);
diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html
index 5a54e44c9..ca5f2585d 100644
--- a/tests/unit/position/position.html
+++ b/tests/unit/position/position.html
@@ -43,5 +43,9 @@
<div style="position: absolute; height: 5000px; width: 5000px;"></div>
+<div id="bug-5280" style="height: 30px; width: 201px;">
+ <div style="width: 50px; height: 10px;"></div>
+</div>
+
</body>
</html>
diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js
index 4d2716ced..57e02da0a 100644
--- a/tests/unit/position/position_core.js
+++ b/tests/unit/position/position_core.js
@@ -330,4 +330,22 @@ test("collision: none, with offset", function() {
}, { top: -13, left: -12 }, "left top, negative offset");
});
+//test('bug #5280: consistent results (avoid fractional values)', function() {
+// var wrapper = $('#bug-5280'),
+// elem = wrapper.children(),
+// offset1 = elem.position({
+// my: 'center',
+// at: 'center',
+// of: wrapper,
+// collision: 'none'
+// }).offset(),
+// offset2 = elem.position({
+// my: 'center',
+// at: 'center',
+// of: wrapper,
+// collision: 'none'
+// }).offset();
+// same(offset1, offset2);
+//});
+
})(jQuery);
diff --git a/tests/unit/slider/slider_events.js b/tests/unit/slider/slider_events.js
index fb9af8155..d7c146d84 100644
--- a/tests/unit/slider/slider_events.js
+++ b/tests/unit/slider/slider_events.js
@@ -3,45 +3,54 @@
*/
(function($) {
-var el;
-
module( "slider: events" );
-test( "start", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
-test( "slide", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
//Specs from http://wiki.jqueryui.com/Slider#specs
//"change callback: triggers when the slider has stopped moving and has a new
// value (even if same as previous value), via mouse(mouseup) or keyboard(keyup)
// or value method/option"
-test( "change", function() {
- expect(8);
+test( "mouse based interaction", function() {
+ expect(4);
- var handle;
- // Test mouseup at end of handle slide (mouse)
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
+ start: function(event, ui) {
+ equals( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
+ },
+ slide: function(event, ui) {
+ equals( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
+ },
+ stop: function(event, ui) {
+ equals( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
+ },
change: function(event, ui) {
- ok( true, "change triggered by mouseup at end of handle slide (mouse)" );
+ equals( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
}
});
el.find( ".ui-slider-handle" ).eq( 0 )
.simulate( "drag", { dx: 10, dy: 10 } );
- reset();
+});
+test( "keyboard based interaction", function() {
+ expect(3);
+
// Test keyup at end of handle slide (keyboard)
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
+ start: function(event, ui) {
+ equals( event.originalEvent.type, "keydown", "start triggered by keydown" );
+ },
+ slide: function(event, ui) {
+ ok( false, "Slider never triggered by keys" );
+ },
+ stop: function(event, ui) {
+ equals( event.originalEvent.type, "keyup", "stop triggered by keyup" );
+ },
change: function(event, ui) {
- ok( true, "change triggered by keyup at end of handle slide (keyboard)" );
+ equals( event.originalEvent.type, "keyup", "change triggered by keyup" );
}
});
@@ -50,9 +59,12 @@ test( "change", function() {
.simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } )
.simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } );
- reset();
+});
+test( "programmatic event triggers", function() {
+ expect(6);
+
// Test value method
- el = $( "<div></div>" )
+ var el = $( "<div></div>" )
.slider({
change: function(event, ui) {
ok( true, "change triggered by value method" );
@@ -94,8 +106,4 @@ test( "change", function() {
});
-test( "stop", function() {
- ok( false, "missing test - untested code is broken code." );
-});
-
}( jQuery ) );
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js
index 88eb26a8f..cc36923b3 100644
--- a/tests/unit/slider/slider_options.js
+++ b/tests/unit/slider/slider_options.js
@@ -11,10 +11,6 @@ function handle() {
module("slider: options");
-test("animate", function() {
- ok(false, "missing test - untested code is broken code.");
-});
-
test("max", function() {
el = $('<div></div>');
@@ -93,7 +89,17 @@ test("range", function() {
});
test("step", function() {
- ok(false, "missing test - untested code is broken code.");
+ var el = $('<div></div>').slider({
+ step: 10
+ });
+ equals( el.slider("value"), 0 )
+ el.slider("value", 1);
+ equals( el.slider("value"), 10 );
+ el.slider("value", 10);
+ equals( el.slider("value"), 10 );
+ el.slider("value", 11);
+ equals( el.slider("value"), 20 );
+ el.slider('destroy');
});
test("value", function() {