From 9786a19c82a8eb50f470d0e2a92126b65e4e8fd9 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 25 Mar 2010 16:40:43 -0400 Subject: Core unit tests: Include testsuite.js for the testswarm include --- tests/unit/core/core.html | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/unit') diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index eb0d2f930..843344ca7 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -11,6 +11,7 @@ + -- cgit v1.2.3 From 9541bd0bf2ca72795e8f2b2c1d3accc32afcac96 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 26 Mar 2010 19:53:43 -0400 Subject: Position: Use parseInt() to prevent fractional pixel values. Fixes #5280 - ui.position generates different position in static context. --- tests/unit/position/position.html | 4 ++++ tests/unit/position/position_core.js | 18 ++++++++++++++++++ ui/jquery.ui.position.js | 4 ++++ 3 files changed, 26 insertions(+) (limited to 'tests/unit') 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 @@
+
+
+
+ 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/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index f01640e18..11f8baa06 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -113,6 +113,10 @@ $.fn.position = function( options ) { position.top -= elemHeight / 2; } + // prevent fractions (see #5280) + position.left = parseInt( position.left ); + position.top = parseInt( position.top ); + $.each( [ "left", "top" ], function( i, dir ) { if ( $.ui.position[ collision[i] ] ) { $.ui.position[ collision[i] ][ dir ]( position, { -- cgit v1.2.3 From 3eee15fca88215446f5036e8fc2c965f5345a3c2 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 01:44:14 +0100 Subject: Slider tests: Split three different change-event tests into three tests, adding start, slide and stop assertions to each, removing placeholders for those other events --- tests/unit/slider/slider_events.js | 58 ++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'tests/unit') 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 = $( "
" ) + var el = $( "
" ) .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 = $( "
" ) + var el = $( "
" ) .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 = $( "
" ) + var el = $( "
" ) .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 ) ); -- cgit v1.2.3 From d969e661643f001837ca07d34f471231886aa2ca Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 02:00:59 +0100 Subject: Slider: Test for test-option, setting the value with the value-method; either test is wrong or the implementation ignores the step-option when set programmatically --- tests/unit/slider/slider_options.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/unit') diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 88eb26a8f..65d308e26 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -93,7 +93,17 @@ test("range", function() { }); test("step", function() { - ok(false, "missing test - untested code is broken code."); + var el = $('
').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() { -- cgit v1.2.3 From ccf85fd3b92a9586f54cc715e031ea51a7a2af64 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 02:01:56 +0100 Subject: Slider: Removing the placeholder for the animate-option, as we generally don't try to unit-test any animations --- tests/unit/slider/slider_options.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 65d308e26..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 = $('
'); -- cgit v1.2.3 From b012de18a47607119fc47a49b22ff2376efa8972 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 07:42:43 +0100 Subject: Accordion unit tests: Further normalization of styles to get consistent results across browsers --- tests/unit/accordion/accordion.html | 3 +-- tests/unit/accordion/accordion_options.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index a7142250e..4173ed9f1 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -25,8 +25,7 @@ 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() { -- cgit v1.2.3 From 11e719f8f84468b7eac44fd19521ddf8eaa360f5 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 08:00:03 +0100 Subject: Updating autocomplete and button unit tests: use equal instead of ok to compare markup, works fine in latest QUnit (escapes all messages correctly) --- tests/unit/autocomplete/autocomplete_methods.js | 3 +-- tests/unit/button/button_methods.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'tests/unit') 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); -- cgit v1.2.3 From d5a6b334669c8024573b8aa52014c83f3823f0c2 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 27 Mar 2010 08:01:41 +0100 Subject: Accordion unit tets: Replacing destory method test with autocomplete/button approach, comparing before/after html - had to add some classes and empty style attributes to ignore class='' and style='', harmless enough --- tests/unit/accordion/accordion.html | 64 ++++++++++++++++--------------- tests/unit/accordion/accordion_methods.js | 18 ++------- 2 files changed, 36 insertions(+), 46 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 4173ed9f1..df0979803 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -38,37 +38,39 @@
-
- There is one obvious advantage: -
-

- You've seen it coming! -
- Buy now and get nothing for free! -
- Well, at least no free beer. Perhaps a bear, if you can afford it. -

-
- Now that you've got... -
-

- your bear, you have to admit it! -
- No, we aren't selling bears. -

-

- We could talk about renting one. -

-
- Rent one bear, ... -
-

- get two for three beer. -

-

- And now, for something completely different. -

-
+
+
+ There is one obvious advantage: +
+

+ You've seen it coming! +
+ Buy now and get nothing for free! +
+ Well, at least no free beer. Perhaps a bear, if you can afford it. +

+
+ Now that you've got... +
+

+ your bear, you have to admit it! +
+ No, we aren't selling bears. +

+

+ We could talk about renting one. +

+
+ Rent one bear, ... +
+

+ get two for three beer. +

+

+ And now, for something completely different. +

+
+