From a1665402511eb99e9c1a29a47262763cb3a3ba68 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 20 Apr 2012 09:38:04 -0400 Subject: Use .jshintrc files. --- tests/.jshintrc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/.jshintrc (limited to 'tests') diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 000000000..2db023452 --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,58 @@ +{ + "browser": true, + "curly": true, + "eqnull": true, + "eqeqeq": true, + "expr": true, + "evil": true, + "jquery": true, + "latedef": true, + "noarg": true, + "onevar": true, + "smarttabs": true, + "trailing": true, + "undef": true, + "predef": [ + "addMonths", + "asyncTest", + "container", + "deepEqual", + "d1", + "d2", + "dlg", + "domEqual", + "drag", + "dragged", + "el", + "equal", + "equalsDate", + "expect", + "Globalize", + "heightAfter", + "init", + "isNotOpen", + "isOpen", + "modal", + "module", + "moved", + "notEqual", + "offsetAfter", + "offsetBefore", + "ok", + "PROP_NAME", + "QUnit", + "restoreScroll", + "shouldBeDroppable", + "shouldmove", + "shouldNotBeDroppable", + "shouldnotmove", + "shouldnotresize", + "shouldresize", + "start", + "strictEqual", + "stop", + "test", + "TestHelpers", + "widthAfter" + ] +} \ No newline at end of file -- cgit v1.2.3 From 31f3d0e6a3af33918cad6f0a12efecc522740d47 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 20 Apr 2012 11:20:50 -0400 Subject: Resizabe tests: Use equal() instead of equals(). --- tests/unit/resizable/resizable_options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index 275639ca1..e10a55a31 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -189,10 +189,10 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("zIndex, applied to all handles", function() { expect(8); - + var target = $('
').resizable({ handles: 'all', zIndex: 100 }); target.children( '.ui-resizable-handle' ).each( function( index, handle ) { - equals( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' ); + equal( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' ); }); }); -- cgit v1.2.3 From c090fe9486700e1c10defba35f272e78459ad566 Mon Sep 17 00:00:00 2001 From: Scott González Date: Fri, 20 Apr 2012 11:23:37 -0400 Subject: Resizable tests: Remove all bad tests. --- tests/unit/resizable/resizable_defaults.js | 5 ++- tests/unit/resizable/resizable_events.js | 12 ------- tests/unit/resizable/resizable_methods.js | 55 ------------------------------ 3 files changed, 4 insertions(+), 68 deletions(-) (limited to 'tests') diff --git a/tests/unit/resizable/resizable_defaults.js b/tests/unit/resizable/resizable_defaults.js index c46e10781..617cdd2ad 100644 --- a/tests/unit/resizable/resizable_defaults.js +++ b/tests/unit/resizable/resizable_defaults.js @@ -19,6 +19,9 @@ TestHelpers.commonWidgetTests('resizable', { maxWidth: null, minHeight: 10, minWidth: 10, - zIndex: 1000 + zIndex: 1000, + + // callbacks + create: null } }); diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js index e8041f064..52d55731c 100644 --- a/tests/unit/resizable/resizable_events.js +++ b/tests/unit/resizable/resizable_events.js @@ -5,16 +5,4 @@ module("resizable: events"); -test("start", function() { - ok(false, "missing test - untested code is broken code."); -}); - -test("resize", function() { - ok(false, "missing test - untested code is broken code."); -}); - -test("stop", function() { - ok(false, "missing test - untested code is broken code."); -}); - })(jQuery); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index 2b4c4256c..87859acf7 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -5,60 +5,5 @@ module("resizable: methods"); -test("init", function() { - expect(6); - - $("
").appendTo('body').resizable().remove(); - ok(true, '.resizable() called on element'); - - $([]).resizable().remove(); - ok(true, '.resizable() called on empty collection'); - - $('
').resizable().remove(); - ok(true, '.resizable() called on disconnected DOMElement'); - - $('
').resizable().resizable("foo").remove(); - ok(true, 'arbitrary method called after init'); - - el = $('
').resizable(); - var foo = el.resizable("option", "foo"); - el.remove(); - ok(true, 'arbitrary option getter after init'); - - $('
').resizable().resizable("option", "foo", "bar").remove(); - ok(true, 'arbitrary option setter after init'); -}); - -test("destroy", function() { - $("
").appendTo('body').resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on element'); - - $([]).resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on empty collection'); - - $('
').resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on disconnected DOMElement'); - - $('
').resizable().resizable("destroy").resizable("foo").remove(); - ok(true, 'arbitrary method called after destroy'); - - var expected = $('
').resizable(), - actual = expected.resizable('destroy'); - equal(actual, expected, 'destroy is chainable'); -}); - -test("enable", function() { - var expected = $('
').resizable(), - actual = expected.resizable('enable'); - equal(actual, expected, 'enable is chainable'); - ok(false, "missing test - untested code is broken code."); -}); - -test("disable", function() { - var expected = $('
').resizable(), - actual = expected.resizable('disable'); - equal(actual, expected, 'disable is chainable'); - ok(false, "missing test - untested code is broken code."); -}); })(jQuery); -- cgit v1.2.3 From ce3c7fab938c755b10d5e55bddccdde1be4819f1 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Sat, 21 Apr 2012 17:49:11 +0200 Subject: Update to official qunit composite addon --- tests/unit/accordion/all.html | 4 +- tests/unit/all-active.html | 4 +- tests/unit/all.html | 4 +- tests/unit/autocomplete/all.html | 4 +- tests/unit/button/all.html | 4 +- tests/unit/core/all.html | 4 +- tests/unit/datepicker/all.html | 4 +- tests/unit/dialog/all.html | 4 +- tests/unit/draggable/all.html | 4 +- tests/unit/droppable/all.html | 4 +- tests/unit/effects/all.html | 4 +- tests/unit/menu/all.html | 4 +- tests/unit/position/all.html | 4 +- tests/unit/progressbar/all.html | 4 +- tests/unit/qunit-composite.css | 13 +++++ tests/unit/qunit-composite.js | 102 +++++++++++++++++++++++++++++++++++++++ tests/unit/resizable/all.html | 4 +- tests/unit/selectable/all.html | 4 +- tests/unit/slider/all.html | 4 +- tests/unit/sortable/all.html | 4 +- tests/unit/spinner/all.html | 4 +- tests/unit/subsuiteRunner.css | 8 --- tests/unit/subsuiteRunner.js | 88 --------------------------------- tests/unit/tabs/all.html | 4 +- tests/unit/tooltip/all.html | 4 +- tests/unit/widget/all.html | 4 +- 26 files changed, 159 insertions(+), 140 deletions(-) create mode 100644 tests/unit/qunit-composite.css create mode 100644 tests/unit/qunit-composite.js delete mode 100644 tests/unit/subsuiteRunner.css delete mode 100644 tests/unit/subsuiteRunner.js (limited to 'tests') diff --git a/tests/unit/accordion/all.html b/tests/unit/accordion/all.html index ec9c003d9..2fb783c1c 100644 --- a/tests/unit/accordion/all.html +++ b/tests/unit/accordion/all.html @@ -7,9 +7,9 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + " ); + asyncTest( "JSHint", function() { + expect( 1 ); + + $.when( + $.ajax({ + url: "../../../ui/.jshintrc", + dataType: "json" + }), + $.ajax({ + url: "../../../ui/jquery.ui." + widget + ".js", + dataType: "text" + }) + ).done(function( hintArgs, srcArgs ) { + var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ), + errors = $.map( JSHINT.errors, function( error ) { + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + }).join( "\n" ); + ok( passed, errors ); + start(); + }) + .fail(function() { + ok( false, "error loading source" ); + start(); + }); + }); +} + function testWidgetDefaults( widget, defaults ) { var pluginDefaults = $.ui[ widget ].prototype.options; @@ -59,6 +93,7 @@ function testBasicUsage( widget ) { TestHelpers.commonWidgetTests = function( widget, settings ) { module( widget + ": common widget" ); + testJshint( widget ); testWidgetDefaults( widget, settings.defaults ); testWidgetOverrides( widget ); testBasicUsage( widget ); @@ -106,4 +141,4 @@ window.domEqual = function( selector, modifier, message ) { QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); }; -}()); +}( jQuery )); -- cgit v1.2.3 From 7a5a77da50e5e2401043410434c49971ce504653 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 23 Apr 2012 10:15:17 -0400 Subject: Tests: Rename {widget}_defaults.js -> {widget}_common.js --- tests/unit/accordion/accordion.html | 8 ++--- tests/unit/accordion/accordion_common.js | 20 +++++++++++++ .../unit/accordion/accordion_common_deprecated.js | 29 ++++++++++++++++++ tests/unit/accordion/accordion_defaults.js | 20 ------------- .../accordion/accordion_defaults_deprecated.js | 29 ------------------ tests/unit/accordion/accordion_deprecated.html | 8 ++--- tests/unit/autocomplete/autocomplete.html | 2 +- tests/unit/autocomplete/autocomplete_common.js | 25 ++++++++++++++++ tests/unit/autocomplete/autocomplete_defaults.js | 25 ---------------- tests/unit/button/button.html | 2 +- tests/unit/button/button_common.js | 14 +++++++++ tests/unit/button/button_defaults.js | 14 --------- tests/unit/dialog/dialog.html | 2 +- tests/unit/dialog/dialog_common.js | 34 ++++++++++++++++++++++ tests/unit/dialog/dialog_defaults.js | 34 ---------------------- tests/unit/draggable/draggable.html | 2 +- tests/unit/draggable/draggable_common.js | 32 ++++++++++++++++++++ tests/unit/draggable/draggable_defaults.js | 32 -------------------- tests/unit/droppable/droppable.html | 2 +- tests/unit/droppable/droppable_common.js | 12 ++++++++ tests/unit/droppable/droppable_defaults.js | 12 -------- tests/unit/menu/menu.html | 2 +- tests/unit/menu/menu_common.js | 16 ++++++++++ tests/unit/menu/menu_defaults.js | 16 ---------- tests/unit/progressbar/progressbar.html | 2 +- tests/unit/progressbar/progressbar_common.js | 10 +++++++ tests/unit/progressbar/progressbar_defaults.js | 10 ------- tests/unit/resizable/resizable.html | 2 +- tests/unit/resizable/resizable_common.js | 27 +++++++++++++++++ tests/unit/resizable/resizable_defaults.js | 27 ----------------- tests/unit/selectable/selectable.html | 2 +- tests/unit/selectable/selectable_common.js | 12 ++++++++ tests/unit/selectable/selectable_defaults.js | 12 -------- tests/unit/slider/slider.html | 2 +- tests/unit/slider/slider_common.js | 19 ++++++++++++ tests/unit/slider/slider_defaults.js | 19 ------------ tests/unit/sortable/sortable.html | 2 +- tests/unit/sortable/sortable_common.js | 30 +++++++++++++++++++ tests/unit/sortable/sortable_defaults.js | 30 ------------------- tests/unit/spinner/spinner.html | 4 +-- tests/unit/spinner/spinner_common.js | 19 ++++++++++++ tests/unit/spinner/spinner_defaults.js | 19 ------------ tests/unit/tabs/tabs.html | 2 +- tests/unit/tabs/tabs_common.js | 16 ++++++++++ tests/unit/tabs/tabs_common_deprecated.js | 29 ++++++++++++++++++ tests/unit/tabs/tabs_defaults.js | 16 ---------- tests/unit/tabs/tabs_defaults_deprecated.js | 29 ------------------ tests/unit/tabs/tabs_deprecated.html | 2 +- tests/unit/tooltip/tooltip.html | 2 +- tests/unit/tooltip/tooltip_common.js | 20 +++++++++++++ tests/unit/tooltip/tooltip_defaults.js | 20 ------------- 51 files changed, 388 insertions(+), 388 deletions(-) create mode 100644 tests/unit/accordion/accordion_common.js create mode 100644 tests/unit/accordion/accordion_common_deprecated.js delete mode 100644 tests/unit/accordion/accordion_defaults.js delete mode 100644 tests/unit/accordion/accordion_defaults_deprecated.js create mode 100644 tests/unit/autocomplete/autocomplete_common.js delete mode 100644 tests/unit/autocomplete/autocomplete_defaults.js create mode 100644 tests/unit/button/button_common.js delete mode 100644 tests/unit/button/button_defaults.js create mode 100644 tests/unit/dialog/dialog_common.js delete mode 100644 tests/unit/dialog/dialog_defaults.js create mode 100644 tests/unit/draggable/draggable_common.js delete mode 100644 tests/unit/draggable/draggable_defaults.js create mode 100644 tests/unit/droppable/droppable_common.js delete mode 100644 tests/unit/droppable/droppable_defaults.js create mode 100644 tests/unit/menu/menu_common.js delete mode 100644 tests/unit/menu/menu_defaults.js create mode 100644 tests/unit/progressbar/progressbar_common.js delete mode 100644 tests/unit/progressbar/progressbar_defaults.js create mode 100644 tests/unit/resizable/resizable_common.js delete mode 100644 tests/unit/resizable/resizable_defaults.js create mode 100644 tests/unit/selectable/selectable_common.js delete mode 100644 tests/unit/selectable/selectable_defaults.js create mode 100644 tests/unit/slider/slider_common.js delete mode 100644 tests/unit/slider/slider_defaults.js create mode 100644 tests/unit/sortable/sortable_common.js delete mode 100644 tests/unit/sortable/sortable_defaults.js create mode 100644 tests/unit/spinner/spinner_common.js delete mode 100644 tests/unit/spinner/spinner_defaults.js create mode 100644 tests/unit/tabs/tabs_common.js create mode 100644 tests/unit/tabs/tabs_common_deprecated.js delete mode 100644 tests/unit/tabs/tabs_defaults.js delete mode 100644 tests/unit/tabs/tabs_defaults_deprecated.js create mode 100644 tests/unit/tooltip/tooltip_common.js delete mode 100644 tests/unit/tooltip/tooltip_defaults.js (limited to 'tests') diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 5c9169ea3..ec7839019 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -26,7 +26,7 @@ - + @@ -93,7 +93,7 @@
  • Amps
  • Effects
  • Accessories
  • - +
  • Bass

    @@ -105,7 +105,7 @@
  • Accessories
  • Accessories
  • Accessories
  • - +
  • Drums

    @@ -113,7 +113,7 @@
  • Acoustic
  • Electronic
  • Accessories
  • - + diff --git a/tests/unit/accordion/accordion_common.js b/tests/unit/accordion/accordion_common.js new file mode 100644 index 000000000..ef24cf25e --- /dev/null +++ b/tests/unit/accordion/accordion_common.js @@ -0,0 +1,20 @@ +TestHelpers.commonWidgetTests( "accordion", { + defaults: { + active: 0, + animate: {}, + collapsible: false, + disabled: false, + event: "click", + header: "> li > :first-child,> :not(li):even", + heightStyle: "auto", + icons: { + "activeHeader": "ui-icon-triangle-1-s", + "header": "ui-icon-triangle-1-e" + }, + + // callbacks + activate: null, + beforeActivate: null, + create: null + } +}); diff --git a/tests/unit/accordion/accordion_common_deprecated.js b/tests/unit/accordion/accordion_common_deprecated.js new file mode 100644 index 000000000..22d5e1289 --- /dev/null +++ b/tests/unit/accordion/accordion_common_deprecated.js @@ -0,0 +1,29 @@ +TestHelpers.commonWidgetTests( "accordion", { + defaults: { + active: 0, + animate: null, + animated: "slide", + autoHeight: true, + clearStyle: false, + collapsible: false, + disabled: false, + event: "click", + fillSpace: false, + header: "> li > :first-child,> :not(li):even", + heightStyle: null, + icons: { + "activeHeader": null, + "header": "ui-icon-triangle-1-e", + "headerSelected": "ui-icon-triangle-1-s" + }, + navigation: false, + navigationFilter: function() {}, + + // callbacks + activate: null, + beforeActivate: null, + change: null, + changestart: null, + create: null + } +}); diff --git a/tests/unit/accordion/accordion_defaults.js b/tests/unit/accordion/accordion_defaults.js deleted file mode 100644 index ef24cf25e..000000000 --- a/tests/unit/accordion/accordion_defaults.js +++ /dev/null @@ -1,20 +0,0 @@ -TestHelpers.commonWidgetTests( "accordion", { - defaults: { - active: 0, - animate: {}, - collapsible: false, - disabled: false, - event: "click", - header: "> li > :first-child,> :not(li):even", - heightStyle: "auto", - icons: { - "activeHeader": "ui-icon-triangle-1-s", - "header": "ui-icon-triangle-1-e" - }, - - // callbacks - activate: null, - beforeActivate: null, - create: null - } -}); diff --git a/tests/unit/accordion/accordion_defaults_deprecated.js b/tests/unit/accordion/accordion_defaults_deprecated.js deleted file mode 100644 index 22d5e1289..000000000 --- a/tests/unit/accordion/accordion_defaults_deprecated.js +++ /dev/null @@ -1,29 +0,0 @@ -TestHelpers.commonWidgetTests( "accordion", { - defaults: { - active: 0, - animate: null, - animated: "slide", - autoHeight: true, - clearStyle: false, - collapsible: false, - disabled: false, - event: "click", - fillSpace: false, - header: "> li > :first-child,> :not(li):even", - heightStyle: null, - icons: { - "activeHeader": null, - "header": "ui-icon-triangle-1-e", - "headerSelected": "ui-icon-triangle-1-s" - }, - navigation: false, - navigationFilter: function() {}, - - // callbacks - activate: null, - beforeActivate: null, - change: null, - changestart: null, - create: null - } -}); diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index 116eb43b5..f3494c6fc 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -23,7 +23,7 @@ - + @@ -91,7 +91,7 @@
  • Amps
  • Effects
  • Accessories
  • - +
  • Bass

    @@ -103,7 +103,7 @@
  • Accessories
  • Accessories
  • Accessories
  • - +
  • Drums

    @@ -111,7 +111,7 @@
  • Acoustic
  • Electronic
  • Accessories
  • - + diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html index 70d2ecfd1..259def349 100644 --- a/tests/unit/autocomplete/autocomplete.html +++ b/tests/unit/autocomplete/autocomplete.html @@ -24,7 +24,7 @@ - + diff --git a/tests/unit/autocomplete/autocomplete_common.js b/tests/unit/autocomplete/autocomplete_common.js new file mode 100644 index 000000000..c090ce4df --- /dev/null +++ b/tests/unit/autocomplete/autocomplete_common.js @@ -0,0 +1,25 @@ +TestHelpers.commonWidgetTests( "autocomplete", { + defaults: { + appendTo: "body", + autoFocus: false, + delay: 300, + disabled: false, + minLength: 1, + position: { + my: "left top", + at: "left bottom", + collision: "none" + }, + source: null, + + // callbacks + change: null, + close: null, + create: null, + focus: null, + open: null, + response: null, + search: null, + select: null + } +}); diff --git a/tests/unit/autocomplete/autocomplete_defaults.js b/tests/unit/autocomplete/autocomplete_defaults.js deleted file mode 100644 index c090ce4df..000000000 --- a/tests/unit/autocomplete/autocomplete_defaults.js +++ /dev/null @@ -1,25 +0,0 @@ -TestHelpers.commonWidgetTests( "autocomplete", { - defaults: { - appendTo: "body", - autoFocus: false, - delay: 300, - disabled: false, - minLength: 1, - position: { - my: "left top", - at: "left bottom", - collision: "none" - }, - source: null, - - // callbacks - change: null, - close: null, - create: null, - focus: null, - open: null, - response: null, - search: null, - select: null - } -}); diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 5ec7e316a..5f27740c4 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -22,8 +22,8 @@ + - diff --git a/tests/unit/button/button_common.js b/tests/unit/button/button_common.js new file mode 100644 index 000000000..ef22d3011 --- /dev/null +++ b/tests/unit/button/button_common.js @@ -0,0 +1,14 @@ +TestHelpers.commonWidgetTests( "button", { + defaults: { + disabled: null, + icons: { + primary: null, + secondary: null + }, + label: null, + text: true, + + // callbacks + create: null + } +}); diff --git a/tests/unit/button/button_defaults.js b/tests/unit/button/button_defaults.js deleted file mode 100644 index ef22d3011..000000000 --- a/tests/unit/button/button_defaults.js +++ /dev/null @@ -1,14 +0,0 @@ -TestHelpers.commonWidgetTests( "button", { - defaults: { - disabled: null, - icons: { - primary: null, - secondary: null - }, - label: null, - text: true, - - // callbacks - create: null - } -}); diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 94b20a225..1f940400c 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -27,8 +27,8 @@ + - diff --git a/tests/unit/dialog/dialog_common.js b/tests/unit/dialog/dialog_common.js new file mode 100644 index 000000000..623908da7 --- /dev/null +++ b/tests/unit/dialog/dialog_common.js @@ -0,0 +1,34 @@ +TestHelpers.commonWidgetTests( "dialog", { + defaults: { + autoOpen: true, + buttons: {}, + closeOnEscape: true, + closeText: 'close', + disabled: false, + dialogClass: '', + draggable: true, + height: 'auto', + hide: null, + maxHeight: false, + maxWidth: false, + minHeight: 150, + minWidth: 150, + modal: false, + position: { + my: 'center', + at: 'center', + of: window, + collision: 'fit', + using: $.ui.dialog.prototype.options.position.using + }, + resizable: true, + show: null, + stack: true, + title: '', + width: 300, + zIndex: 1000, + + // callbacks + create: null + } +}); diff --git a/tests/unit/dialog/dialog_defaults.js b/tests/unit/dialog/dialog_defaults.js deleted file mode 100644 index 623908da7..000000000 --- a/tests/unit/dialog/dialog_defaults.js +++ /dev/null @@ -1,34 +0,0 @@ -TestHelpers.commonWidgetTests( "dialog", { - defaults: { - autoOpen: true, - buttons: {}, - closeOnEscape: true, - closeText: 'close', - disabled: false, - dialogClass: '', - draggable: true, - height: 'auto', - hide: null, - maxHeight: false, - maxWidth: false, - minHeight: 150, - minWidth: 150, - modal: false, - position: { - my: 'center', - at: 'center', - of: window, - collision: 'fit', - using: $.ui.dialog.prototype.options.position.using - }, - resizable: true, - show: null, - stack: true, - title: '', - width: 300, - zIndex: 1000, - - // callbacks - create: null - } -}); diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 5be71f460..acc50effe 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/draggable/draggable_common.js b/tests/unit/draggable/draggable_common.js new file mode 100644 index 000000000..b47b139cd --- /dev/null +++ b/tests/unit/draggable/draggable_common.js @@ -0,0 +1,32 @@ +TestHelpers.commonWidgetTests( "draggable", { + defaults: { + addClasses: true, + appendTo: "parent", + axis: false, + cancel: ":input,option", + connectToSortable: false, + containment: false, + cursor: "auto", + cursorAt: false, + delay: 0, + disabled: false, + distance: 1, + grid: false, + handle: false, + helper: "original", + iframeFix: false, + opacity: false, + refreshPositions: false, + revert: false, + revertDuration: 500, + scroll: true, + scrollSensitivity: 20, + scrollSpeed: 20, + scope: "default", + snap: false, + snapMode: "both", + snapTolerance: 20, + stack: false, + zIndex: false + } +}); diff --git a/tests/unit/draggable/draggable_defaults.js b/tests/unit/draggable/draggable_defaults.js deleted file mode 100644 index b47b139cd..000000000 --- a/tests/unit/draggable/draggable_defaults.js +++ /dev/null @@ -1,32 +0,0 @@ -TestHelpers.commonWidgetTests( "draggable", { - defaults: { - addClasses: true, - appendTo: "parent", - axis: false, - cancel: ":input,option", - connectToSortable: false, - containment: false, - cursor: "auto", - cursorAt: false, - delay: 0, - disabled: false, - distance: 1, - grid: false, - handle: false, - helper: "original", - iframeFix: false, - opacity: false, - refreshPositions: false, - revert: false, - revertDuration: 500, - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - scope: "default", - snap: false, - snapMode: "both", - snapTolerance: 20, - stack: false, - zIndex: false - } -}); diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index abf94f0c7..eb2215763 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -24,8 +24,8 @@ + - diff --git a/tests/unit/droppable/droppable_common.js b/tests/unit/droppable/droppable_common.js new file mode 100644 index 000000000..985dba06d --- /dev/null +++ b/tests/unit/droppable/droppable_common.js @@ -0,0 +1,12 @@ +TestHelpers.commonWidgetTests( "droppable", { + defaults: { + accept: "*", + activeClass: false, + addClasses: true, + disabled: false, + greedy: false, + hoverClass: false, + scope: "default", + tolerance: "intersect" + } +}); diff --git a/tests/unit/droppable/droppable_defaults.js b/tests/unit/droppable/droppable_defaults.js deleted file mode 100644 index 985dba06d..000000000 --- a/tests/unit/droppable/droppable_defaults.js +++ /dev/null @@ -1,12 +0,0 @@ -TestHelpers.commonWidgetTests( "droppable", { - defaults: { - accept: "*", - activeClass: false, - addClasses: true, - disabled: false, - greedy: false, - hoverClass: false, - scope: "default", - tolerance: "intersect" - } -}); diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 9a598ec8d..54a2ecaa0 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/menu/menu_common.js b/tests/unit/menu/menu_common.js new file mode 100644 index 000000000..ddcdbebf2 --- /dev/null +++ b/tests/unit/menu/menu_common.js @@ -0,0 +1,16 @@ +TestHelpers.commonWidgetTests( "menu", { + defaults: { + disabled: false, + menus: "ul", + position: { + my: "left top", + at: "right top" + }, + + // callbacks + blur: null, + create: null, + focus: null, + select: null + } +}); diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_defaults.js deleted file mode 100644 index ddcdbebf2..000000000 --- a/tests/unit/menu/menu_defaults.js +++ /dev/null @@ -1,16 +0,0 @@ -TestHelpers.commonWidgetTests( "menu", { - defaults: { - disabled: false, - menus: "ul", - position: { - my: "left top", - at: "right top" - }, - - // callbacks - blur: null, - create: null, - focus: null, - select: null - } -}); diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index 8b55f5a89..f6156d0bb 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -22,8 +22,8 @@ + - diff --git a/tests/unit/progressbar/progressbar_common.js b/tests/unit/progressbar/progressbar_common.js new file mode 100644 index 000000000..2f97a78bb --- /dev/null +++ b/tests/unit/progressbar/progressbar_common.js @@ -0,0 +1,10 @@ +TestHelpers.commonWidgetTests( "progressbar", { + defaults: { + disabled: false, + value: 0, + max: 100, + + //callbacks + create: null + } +}); diff --git a/tests/unit/progressbar/progressbar_defaults.js b/tests/unit/progressbar/progressbar_defaults.js deleted file mode 100644 index 2f97a78bb..000000000 --- a/tests/unit/progressbar/progressbar_defaults.js +++ /dev/null @@ -1,10 +0,0 @@ -TestHelpers.commonWidgetTests( "progressbar", { - defaults: { - disabled: false, - value: 0, - max: 100, - - //callbacks - create: null - } -}); diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 4e886d2fd..028087842 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/resizable/resizable_common.js b/tests/unit/resizable/resizable_common.js new file mode 100644 index 000000000..617cdd2ad --- /dev/null +++ b/tests/unit/resizable/resizable_common.js @@ -0,0 +1,27 @@ +TestHelpers.commonWidgetTests('resizable', { + defaults: { + alsoResize: false, + animate: false, + animateDuration: 'slow', + animateEasing: 'swing', + aspectRatio: false, + autoHide: false, + cancel: ':input,option', + containment: false, + delay: 0, + disabled: false, + distance: 1, + ghost: false, + grid: false, + handles: 'e,s,se', + helper: false, + maxHeight: null, + maxWidth: null, + minHeight: 10, + minWidth: 10, + zIndex: 1000, + + // callbacks + create: null + } +}); diff --git a/tests/unit/resizable/resizable_defaults.js b/tests/unit/resizable/resizable_defaults.js deleted file mode 100644 index 617cdd2ad..000000000 --- a/tests/unit/resizable/resizable_defaults.js +++ /dev/null @@ -1,27 +0,0 @@ -TestHelpers.commonWidgetTests('resizable', { - defaults: { - alsoResize: false, - animate: false, - animateDuration: 'slow', - animateEasing: 'swing', - aspectRatio: false, - autoHide: false, - cancel: ':input,option', - containment: false, - delay: 0, - disabled: false, - distance: 1, - ghost: false, - grid: false, - handles: 'e,s,se', - helper: false, - maxHeight: null, - maxWidth: null, - minHeight: 10, - minWidth: 10, - zIndex: 1000, - - // callbacks - create: null - } -}); diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index 4f70e8dd4..af4e6d20e 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/selectable/selectable_common.js b/tests/unit/selectable/selectable_common.js new file mode 100644 index 000000000..27714d0ae --- /dev/null +++ b/tests/unit/selectable/selectable_common.js @@ -0,0 +1,12 @@ +TestHelpers.commonWidgetTests('selectable', { + defaults: { + appendTo: 'body', + autoRefresh: true, + cancel: ':input,option', + delay: 0, + disabled: false, + distance: 0, + filter: '*', + tolerance: 'touch' + } +}); diff --git a/tests/unit/selectable/selectable_defaults.js b/tests/unit/selectable/selectable_defaults.js deleted file mode 100644 index 27714d0ae..000000000 --- a/tests/unit/selectable/selectable_defaults.js +++ /dev/null @@ -1,12 +0,0 @@ -TestHelpers.commonWidgetTests('selectable', { - defaults: { - appendTo: 'body', - autoRefresh: true, - cancel: ':input,option', - delay: 0, - disabled: false, - distance: 0, - filter: '*', - tolerance: 'touch' - } -}); diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index 60d124b7a..a63196219 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/slider/slider_common.js b/tests/unit/slider/slider_common.js new file mode 100644 index 000000000..8a0b347f3 --- /dev/null +++ b/tests/unit/slider/slider_common.js @@ -0,0 +1,19 @@ +TestHelpers.commonWidgetTests( "slider", { + defaults: { + animate: false, + cancel: ':input,option', + delay: 0, + disabled: false, + distance: 0, + max: 100, + min: 0, + orientation: 'horizontal', + range: false, + step: 1, + value: 0, + values: null, + + // callbacks + create: null + } +}); diff --git a/tests/unit/slider/slider_defaults.js b/tests/unit/slider/slider_defaults.js deleted file mode 100644 index 8a0b347f3..000000000 --- a/tests/unit/slider/slider_defaults.js +++ /dev/null @@ -1,19 +0,0 @@ -TestHelpers.commonWidgetTests( "slider", { - defaults: { - animate: false, - cancel: ':input,option', - delay: 0, - disabled: false, - distance: 0, - max: 100, - min: 0, - orientation: 'horizontal', - range: false, - step: 1, - value: 0, - values: null, - - // callbacks - create: null - } -}); diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index a20eb7109..4ed4f92ce 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -23,8 +23,8 @@ + - diff --git a/tests/unit/sortable/sortable_common.js b/tests/unit/sortable/sortable_common.js new file mode 100644 index 000000000..b5fc05a5d --- /dev/null +++ b/tests/unit/sortable/sortable_common.js @@ -0,0 +1,30 @@ +TestHelpers.commonWidgetTests( "sortable", { + defaults: { + appendTo: "parent", + axis: false, + cancel: ":input,option", + connectWith: false, + containment: false, + cursor: "auto", + cursorAt: false, + delay: 0, + disabled: false, + distance: 1, + dropOnEmpty: true, + forcePlaceholderSize: false, + forceHelperSize: false, + grid: false, + handle: false, + helper: "original", + items: "> *", + opacity: false, + placeholder: false, + revert: false, + scroll: true, + scrollSensitivity: 20, + scrollSpeed: 20, + scope: "default", + tolerance: "intersect", + zIndex: 1000 + } +}); diff --git a/tests/unit/sortable/sortable_defaults.js b/tests/unit/sortable/sortable_defaults.js deleted file mode 100644 index b5fc05a5d..000000000 --- a/tests/unit/sortable/sortable_defaults.js +++ /dev/null @@ -1,30 +0,0 @@ -TestHelpers.commonWidgetTests( "sortable", { - defaults: { - appendTo: "parent", - axis: false, - cancel: ":input,option", - connectWith: false, - containment: false, - cursor: "auto", - cursorAt: false, - delay: 0, - disabled: false, - distance: 1, - dropOnEmpty: true, - forcePlaceholderSize: false, - forceHelperSize: false, - grid: false, - handle: false, - helper: "original", - items: "> *", - opacity: false, - placeholder: false, - revert: false, - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - scope: "default", - tolerance: "intersect", - zIndex: 1000 - } -}); diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index 0c01a5f48..e495abe1b 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -3,7 +3,7 @@ jQuery UI Spinner Test Suite - + @@ -27,8 +27,8 @@ + - diff --git a/tests/unit/spinner/spinner_common.js b/tests/unit/spinner/spinner_common.js new file mode 100644 index 000000000..4f05b1e63 --- /dev/null +++ b/tests/unit/spinner/spinner_common.js @@ -0,0 +1,19 @@ +TestHelpers.commonWidgetTests( "spinner", { + defaults: { + culture: null, + disabled: false, + incremental: true, + max: null, + min: null, + numberFormat: null, + page: 10, + step: 1, + + // callbacks + change: null, + create: null, + spin: null, + start: null, + stop: null + } +}); diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_defaults.js deleted file mode 100644 index 4f05b1e63..000000000 --- a/tests/unit/spinner/spinner_defaults.js +++ /dev/null @@ -1,19 +0,0 @@ -TestHelpers.commonWidgetTests( "spinner", { - defaults: { - culture: null, - disabled: false, - incremental: true, - max: null, - min: null, - numberFormat: null, - page: 10, - step: 1, - - // callbacks - change: null, - create: null, - spin: null, - start: null, - stop: null - } -}); diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 7f60ad277..a79d30e0e 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -26,7 +26,7 @@ - + diff --git a/tests/unit/tabs/tabs_common.js b/tests/unit/tabs/tabs_common.js new file mode 100644 index 000000000..7ffb05da4 --- /dev/null +++ b/tests/unit/tabs/tabs_common.js @@ -0,0 +1,16 @@ +TestHelpers.commonWidgetTests( "tabs", { + defaults: { + active: null, + collapsible: false, + disabled: false, + event: "click", + fx: null, + + // callbacks + activate: null, + beforeActivate: null, + beforeLoad: null, + create: null, + load: null + } +}); diff --git a/tests/unit/tabs/tabs_common_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js new file mode 100644 index 000000000..fdcff21b3 --- /dev/null +++ b/tests/unit/tabs/tabs_common_deprecated.js @@ -0,0 +1,29 @@ +TestHelpers.commonWidgetTests( "tabs", { + defaults: { + active: null, + ajaxOptions: null, + cache: false, + collapsible: false, + cookie: null, + disabled: false, + event: "click", + fx: null, + idPrefix: "ui-tabs-", + panelTemplate: "
    ", + spinner: "Loading…", + tabTemplate: "
  • #{label}
  • ", + + // callbacks + activate: null, + add: null, + beforeActivate: null, + beforeLoad: null, + create: null, + disable: null, + enable: null, + load: null, + remove: null, + select: null, + show: null + } +}); diff --git a/tests/unit/tabs/tabs_defaults.js b/tests/unit/tabs/tabs_defaults.js deleted file mode 100644 index 7ffb05da4..000000000 --- a/tests/unit/tabs/tabs_defaults.js +++ /dev/null @@ -1,16 +0,0 @@ -TestHelpers.commonWidgetTests( "tabs", { - defaults: { - active: null, - collapsible: false, - disabled: false, - event: "click", - fx: null, - - // callbacks - activate: null, - beforeActivate: null, - beforeLoad: null, - create: null, - load: null - } -}); diff --git a/tests/unit/tabs/tabs_defaults_deprecated.js b/tests/unit/tabs/tabs_defaults_deprecated.js deleted file mode 100644 index fdcff21b3..000000000 --- a/tests/unit/tabs/tabs_defaults_deprecated.js +++ /dev/null @@ -1,29 +0,0 @@ -TestHelpers.commonWidgetTests( "tabs", { - defaults: { - active: null, - ajaxOptions: null, - cache: false, - collapsible: false, - cookie: null, - disabled: false, - event: "click", - fx: null, - idPrefix: "ui-tabs-", - panelTemplate: "
    ", - spinner: "Loading…", - tabTemplate: "
  • #{label}
  • ", - - // callbacks - activate: null, - add: null, - beforeActivate: null, - beforeLoad: null, - create: null, - disable: null, - enable: null, - load: null, - remove: null, - select: null, - show: null - } -}); diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index c22ec3369..9bb8e413e 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -24,7 +24,7 @@ - + diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index b5e8558e5..d1f54d544 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -23,7 +23,7 @@ - + diff --git a/tests/unit/tooltip/tooltip_common.js b/tests/unit/tooltip/tooltip_common.js new file mode 100644 index 000000000..d12ee9519 --- /dev/null +++ b/tests/unit/tooltip/tooltip_common.js @@ -0,0 +1,20 @@ +TestHelpers.commonWidgetTests( "tooltip", { + defaults: { + content: function() {}, + disabled: false, + hide: true, + items: "[title]", + position: { + my: "left+15 center", + at: "right center", + collision: "flipfit flipfit" + }, + show: true, + tooltipClass: null, + + // callbacks + close: null, + create: null, + open: null + } +}); diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js deleted file mode 100644 index d12ee9519..000000000 --- a/tests/unit/tooltip/tooltip_defaults.js +++ /dev/null @@ -1,20 +0,0 @@ -TestHelpers.commonWidgetTests( "tooltip", { - defaults: { - content: function() {}, - disabled: false, - hide: true, - items: "[title]", - position: { - my: "left+15 center", - at: "right center", - collision: "flipfit flipfit" - }, - show: true, - tooltipClass: null, - - // callbacks - close: null, - create: null, - open: null - } -}); -- cgit v1.2.3 From b042f8ebd68e21155edb090917051353fe7a0162 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 23 Apr 2012 10:43:01 -0400 Subject: Tests: Moved loadResources to TestHelpers. --- tests/resource_loader.js | 40 -------------------------- tests/unit/accordion/accordion.html | 12 ++++---- tests/unit/accordion/accordion_deprecated.html | 12 ++++---- tests/unit/autocomplete/autocomplete.html | 12 ++++---- tests/unit/button/button.html | 12 ++++---- tests/unit/core/core.html | 12 ++++---- tests/unit/datepicker/datepicker.html | 12 ++++---- tests/unit/dialog/dialog.html | 12 ++++---- tests/unit/draggable/draggable.html | 12 ++++---- tests/unit/droppable/droppable.html | 12 ++++---- tests/unit/effects/effects.html | 11 ++++--- tests/unit/menu/menu.html | 12 ++++---- tests/unit/position/position.html | 12 ++++---- tests/unit/position/position_deprecated.html | 12 ++++---- tests/unit/progressbar/progressbar.html | 12 ++++---- tests/unit/resizable/resizable.html | 12 ++++---- tests/unit/selectable/selectable.html | 12 ++++---- tests/unit/slider/slider.html | 12 ++++---- tests/unit/sortable/sortable.html | 12 ++++---- tests/unit/spinner/spinner.html | 12 ++++---- tests/unit/tabs/tabs.html | 12 ++++---- tests/unit/tabs/tabs_deprecated.html | 12 ++++---- tests/unit/testsuite.js | 39 +++++++++++++++++++------ tests/unit/tooltip/tooltip.html | 12 ++++---- tests/unit/widget/widget.html | 12 ++++---- 25 files changed, 145 insertions(+), 209 deletions(-) delete mode 100644 tests/resource_loader.js (limited to 'tests') diff --git a/tests/resource_loader.js b/tests/resource_loader.js deleted file mode 100644 index 9a03411a2..000000000 --- a/tests/resource_loader.js +++ /dev/null @@ -1,40 +0,0 @@ -(function( $ ) { - -var parts = document.location.search.slice( 1 ).split( "&" ), - length = parts.length, - i = 0, - current, - min; - -for ( ; i < length; i++ ) { - current = parts[ i ].split( "=" ); - if ( current[ 0 ] === "min" ) { - min = current[ 1 ]; - break; - } -} - -function includeStyle( url ) { - document.write( "" ); -} - -function includeScript( url ) { - document.write( "" ); -} - -window.loadResources = min ? - function() { - // TODO: proper include with theme images - includeStyle( "dist/jquery-ui.min.css" ); - includeScript( "dist/jquery-ui.min.js" ); - } : - function( resources ) { - $.each( resources.css || [], function( i, resource ) { - includeStyle( "themes/base/jquery." + resource + ".css" ); - }); - $.each( resources.js || [], function( i, resource ) { - includeScript( resource ); - }); - }; - -})( jQuery ); diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index ec7839019..b3b7caeae 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -8,9 +8,12 @@ - + + + + - - - - - diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index f3494c6fc..dfb9fa90e 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -5,9 +5,12 @@ jQuery UI Accordion Test Suite - + + + + - - - - - diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html index 259def349..571c62033 100644 --- a/tests/unit/autocomplete/autocomplete.html +++ b/tests/unit/autocomplete/autocomplete.html @@ -5,9 +5,12 @@ jQuery UI Autocomplete Test Suite - + + + + - - - - - diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 5f27740c4..b79ca1dc6 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -5,9 +5,12 @@ jQuery UI Button Test Suite - + + + + - - - - - diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 3b1dc1fc8..3baf852bb 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -5,17 +5,15 @@ jQuery UI Core Test Suite - - - + diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index 592db53cc..bfff32d32 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -5,9 +5,12 @@ jQuery UI Datepicker Test Suite - + + + + - - - - - diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 1f940400c..d804807f2 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -6,9 +6,12 @@ - + + + + - - - - - diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index acc50effe..09bc191c9 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -5,9 +5,12 @@ jQuery UI Draggable Test Suite - + + + + - - - - - diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index eb2215763..49ebf6beb 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -5,9 +5,12 @@ jQuery UI Droppable Test Suite - + + + + - - - - - diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 06023c55d..1fd94182d 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -8,9 +8,12 @@ - + + + + - - - - diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 54a2ecaa0..fca45697f 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -5,9 +5,12 @@ jQuery UI Menu Test Suite - + + + + - - - - - diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html index 115adc3e9..3ea7750d7 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -8,17 +8,15 @@ - - - + diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html index ee9be189d..c7a9b6bce 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -5,17 +5,15 @@ jQuery UI Position Test Suite - - - + diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index f6156d0bb..70a4abe56 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -5,9 +5,12 @@ jQuery UI Progressbar Test Suite - + + + + - - - - - diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 028087842..9baa67493 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -5,9 +5,12 @@ jQuery UI Resizable Test Suite - + + + + - - - - - diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index af4e6d20e..7b0ca6ffe 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -5,9 +5,12 @@ jQuery UI Selectable Test Suite - + + + + - - - - - diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index a63196219..3aec78b4b 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -5,9 +5,12 @@ jQuery UI Slider Test Suite - + + + + - - - - - diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index 4ed4f92ce..c84c62197 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -5,9 +5,12 @@ jQuery UI Sortable Test Suite - + + + + - - - - - diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index e495abe1b..b7f4a532a 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -8,9 +8,12 @@ - + + + + - - - - - diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index a79d30e0e..fc7bfeedf 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -8,9 +8,12 @@ - + + + + - - - - - diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index 9bb8e413e..0c7611c9d 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -6,9 +6,12 @@ - + + + + - - - - - diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 70d035684..6720000f1 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -2,12 +2,35 @@ window.TestHelpers = {}; +function includeStyle( url ) { + document.write( "" ); +} + +function includeScript( url ) { + document.write( "" ); +} + +TestHelpers.loadResources = QUnit.urlParams.min ? + function() { + // TODO: proper include with theme images + includeStyle( "dist/jquery-ui.min.css" ); + includeScript( "dist/jquery-ui.min.js" ); + } : + function( resources ) { + $.each( resources.css || [], function( i, resource ) { + includeStyle( "themes/base/jquery." + resource + ".css" ); + }); + $.each( resources.js || [], function( i, resource ) { + includeScript( resource ); + }); + }; + function testJshint( widget ) { if ( QUnit.urlParams.nojshint ) { return; } - document.write( "" ); + includeScript( "external/jshint.js" ); asyncTest( "JSHint", function() { expect( 1 ); @@ -58,17 +81,15 @@ function testWidgetDefaults( widget, defaults ) { }); } -var privateMethods = [ - "_createWidget", - "destroy", - "option", - "_trigger" -]; - function testWidgetOverrides( widget ) { if ( $.uiBackCompat === false ) { test( "$.widget overrides", function() { - $.each( privateMethods, function( i, method ) { + $.each([ + "_createWidget", + "destroy", + "option", + "_trigger" + ], function( i, method ) { strictEqual( $.ui[ widget ].prototype[ method ], $.Widget.prototype[ method ], "should not override " + method ); }); diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index d1f54d544..d20ba8578 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -5,9 +5,12 @@ jQuery UI Tooltip Test Suite - + + + + - - - - - diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index 6f4caaa6c..15eaee6aa 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -5,9 +5,12 @@ jQuery UI Widget Test Suite - + + + + - - - - - -- cgit v1.2.3 From 3cb9ab723a23462d5b4e1959db267fd6d147ef40 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 23 Apr 2012 10:47:43 -0400 Subject: Tests: Add custom URL configs to QUnit.config.urlConfig for discoverability. --- tests/unit/testsuite.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 6720000f1..7e505979c 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -10,6 +10,7 @@ function includeScript( url ) { document.write( "" ); } +QUnit.config.urlConfig.push( "min" ); TestHelpers.loadResources = QUnit.urlParams.min ? function() { // TODO: proper include with theme images @@ -25,6 +26,7 @@ TestHelpers.loadResources = QUnit.urlParams.min ? }); }; +QUnit.config.urlConfig.push( "nojshint" ); function testJshint( widget ) { if ( QUnit.urlParams.nojshint ) { return; -- cgit v1.2.3 From 6ccfb20c8bc59345ee5fc8ae5af0c90c4d6c7294 Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 23 Apr 2012 18:13:40 +0200 Subject: Grunt: Add JSHINT to predefs for tests --- tests/.jshintrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/.jshintrc b/tests/.jshintrc index 2db023452..783237218 100644 --- a/tests/.jshintrc +++ b/tests/.jshintrc @@ -53,6 +53,7 @@ "stop", "test", "TestHelpers", - "widthAfter" + "widthAfter", + "JSHINT" ] } \ No newline at end of file -- cgit v1.2.3 From 15705723b2d170f70c3ef408b5b4dca83c84e586 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 23 Apr 2012 12:23:43 -0400 Subject: Position tests: Removed unused elements. --- tests/unit/position/position.html | 8 -------- tests/unit/position/position_deprecated.html | 8 -------- 2 files changed, 16 deletions(-) (limited to 'tests') diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html index 3ea7750d7..396e3e13e 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -49,14 +49,6 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6
    -
    -
    -
    -
    -
    -
    -
    -
    diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html index c7a9b6bce..2a7769107 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -44,14 +44,6 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6
    -
    -
    -
    -
    -
    -
    -
    -
    -- cgit v1.2.3 From 22edb7755923d76c5ecd77f973d49b4c9ce68d1f Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Mon, 23 Apr 2012 18:44:17 +0200 Subject: Fix various issues in our html files, second batch --- demos/menu/default.html | 4 +- demos/menu/navigationmenu.html | 2 +- demos/menu/topalignmenu.html | 2 +- tests/static/icons.html | 7 +- tests/unit/core/core.html | 12 +-- tests/visual/theme.html | 152 +++++++++++++++++------------------ tests/visual/tooltip/animations.html | 1 + tests/visual/tooltip/tooltip.html | 1 + 8 files changed, 92 insertions(+), 89 deletions(-) (limited to 'tests') diff --git a/demos/menu/default.html b/demos/menu/default.html index 9f2e21622..b1c0b9fbb 100644 --- a/demos/menu/default.html +++ b/demos/menu/default.html @@ -1,7 +1,7 @@ - + jQuery UI Menu - Default demo @@ -15,7 +15,7 @@ }); diff --git a/demos/menu/navigationmenu.html b/demos/menu/navigationmenu.html index 970b20890..8c7b2b993 100644 --- a/demos/menu/navigationmenu.html +++ b/demos/menu/navigationmenu.html @@ -1,7 +1,7 @@ - + jQuery UI Menu - Navigation Menu demo diff --git a/demos/menu/topalignmenu.html b/demos/menu/topalignmenu.html index 42721fe9d..7b7e052e4 100644 --- a/demos/menu/topalignmenu.html +++ b/demos/menu/topalignmenu.html @@ -1,7 +1,7 @@ - + Menu Demo: Top-aligned Menu diff --git a/tests/static/icons.html b/tests/static/icons.html index af2833442..adaf5f1cd 100644 --- a/tests/static/icons.html +++ b/tests/static/icons.html @@ -16,12 +16,13 @@ ul {margin: 0; padding: 0;} td div {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left; list-style: none;} span.ui-icon { float: left; margin: 0 4px;} + .icon-collection { border-spacing: 0; border-collapse: collapse; } @@ -28,26 +28,26 @@ // Accordion $(".accordion").accordion({ header: "h3" }); $(".accordion").last().accordion("option", "icons", false); - - + + // Tabs $('#tabs').tabs(); - - // Dialog + + // Dialog $('#dialog').dialog({ autoOpen: false, width: 600, buttons: { - "Ok": function() { - $(this).dialog("close"); - }, - "Cancel": function() { - $(this).dialog("close"); - } + "Ok": function() { + $(this).dialog("close"); + }, + "Cancel": function() { + $(this).dialog("close"); + } } }); - + // Dialog Link $('#dialog_link').click(function(){ $('#dialog').dialog('open'); @@ -59,19 +59,19 @@ inline: true, showWeek: true }); - + $('#multidatepicker').datepicker({ numberOfMonths: 3, showButtonPanel: true, inline: true }); - + // Slider $('.slider').slider({ range: true, values: [17, 67] }); - + $("#eq > span").each(function() { var value = parseInt($(this).text()); $(this).empty().slider({ @@ -81,19 +81,19 @@ orientation: "vertical" }); }); - - + + // Progressbar $("#progressbar").progressbar({ - value: 20 + value: 20 }); - + //hover states on the static widgets $('#dialog_link, ul#icons li').hover( - function() { $(this).addClass('ui-state-hover'); }, + function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } ); - + $(".buttonset > button").button() .next() .button({ @@ -104,8 +104,8 @@ }) .parent() .buttonset(); - - + + $('#beginning').button({ text: false, icons: { @@ -144,7 +144,7 @@ }); $("#shuffle").button(); $("#repeat").buttonset(); - + }); +
    - +

    Accordion

    @@ -201,8 +201,8 @@
    - - + +

    Tabs

    @@ -215,20 +215,20 @@
    Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.
    Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.
    - +

    Dialog

    Open Dialog

    - +
    Inline Dialogclose

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    - - + +

    Overlay and Shadow Classes (not currently used in UI widgets)

    Lorem ipsum dolor sit amet, Nulla nec tortor. Donec id elit quis purus consectetur consequat.

    Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci.

    Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat.

    Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam.

    Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante.

    Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi.

    - +
    @@ -236,24 +236,24 @@

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    - + - +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

    - - - + + +

    Framework Icons (content color preview)

      - +
    • - +
    • @@ -263,7 +263,7 @@
    • - +
    • @@ -273,7 +273,7 @@
    • - +
    • @@ -283,7 +283,7 @@
    • - +
    • @@ -293,7 +293,7 @@
    • - +
    • @@ -303,7 +303,7 @@
    • - +
    • @@ -313,7 +313,7 @@
    • - +
    • @@ -323,7 +323,7 @@
    • - +
    • @@ -333,7 +333,7 @@
    • - +
    • @@ -343,7 +343,7 @@
    • - +
    • @@ -353,7 +353,7 @@
    • - +
    • @@ -363,7 +363,7 @@
    • - +
    • @@ -373,7 +373,7 @@
    • - +
    • @@ -384,7 +384,7 @@
    • - +
    • @@ -396,7 +396,7 @@
    • - +
    • @@ -406,7 +406,7 @@
    • - +
    • @@ -416,7 +416,7 @@
    • - +
    • @@ -426,7 +426,7 @@
    • - +
    • @@ -436,7 +436,7 @@
    • - +
    • @@ -444,7 +444,7 @@
    - +

    Slider

    @@ -461,8 +461,8 @@ 70
    - - + +

    Datepicker

    @@ -471,35 +471,35 @@
    - - + + -

    Progressbar

    +

    Progressbar

    - +

    Highlight / Error

    -
    +

    Hey! Sample ui-state-highlight style.


    -
    -

    +

    +

    Alert: Sample ui-state-error style.

    - +

    Button

    - +
    - + @@ -507,18 +507,18 @@ - + - + - - + + - + - - - - - - - -

    #5254 - Input, button and anchor buttons aren't consistent in IE7

    - -
    -

    Screenshot from ticket:

    -
    -
    - -
    - -
    -

    Visual test:

    -
    -
    - - - Anchor -
    -
    -

    User agent:

    -
    -

    -
    -
    - - - diff --git a/tests/visual/compound/accordion_dialog.html b/tests/visual/compound/accordion_dialog.html index df179ff6a..f7965fa83 100644 --- a/tests/visual/compound/accordion_dialog.html +++ b/tests/visual/compound/accordion_dialog.html @@ -134,7 +134,8 @@ Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit a

    Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis. -

    +

    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.

    diff --git a/tests/visual/compound/datepicker_dialog.html b/tests/visual/compound/datepicker_dialog.html index 885edb4a6..a5a3202e1 100644 --- a/tests/visual/compound/datepicker_dialog.html +++ b/tests/visual/compound/datepicker_dialog.html @@ -89,7 +89,8 @@ Fusce erat sem, dictum in bibendum ac, feugiat ut odio. Duis aliquam felis sit a

    Cras a augue dui, vitae tincidunt enim. In hac habitasse platea dictumst. Proin nec magna sed nulla mollis tempus id ut lectus. Morbi volutpat ultricies ipsum, quis imperdiet libero tempor nec. Donec bibendum ornare blandit. Aliquam rutrum risus non turpis commodo non commodo erat molestie. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut fermentum, magna vel euismod convallis, mi magna vehicula velit, aliquet rhoncus ipsum massa et nunc. Nullam blandit purus non neque ullamcorper a aliquet nisl tristique. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sit amet velit magna, sit amet rutrum dui. Donec elementum mi sed velit consectetur vulputate. Sed interdum adipiscing mattis. -

    +

    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vitae urna quam. Fusce adipiscing erat eget magna malesuada vel mollis ligula ullamcorper. Donec pulvinar, libero et vehicula facilisis, odio orci fringilla magna, non ultricies ipsum justo a tellus. Proin facilisis magna vitae quam vestibulum tempor. Aenean semper placerat posuere. In nisi diam, ullamcorper sit amet viverra sed, pretium sed neque. Sed posuere vulputate mauris vitae placerat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam in odio elit, non tempor felis. Integer non iaculis ante. Sed erat mauris, aliquam nec consequat id, congue id libero. Maecenas elementum gravida tincidunt. Suspendisse lacinia enim sit amet nulla cursus pulvinar.

    diff --git a/tests/visual/compound/sortable_accordion_sortable_tabs.html b/tests/visual/compound/sortable_accordion_sortable_tabs.html index ac90f1a09..a0b65d458 100644 --- a/tests/visual/compound/sortable_accordion_sortable_tabs.html +++ b/tests/visual/compound/sortable_accordion_sortable_tabs.html @@ -69,7 +69,7 @@

    -
    +

    Accordion Header 1

    diff --git a/tests/visual/compound/widgets_in_dialog.html b/tests/visual/compound/widgets_in_dialog.html index 89ea875d1..e155533f5 100644 --- a/tests/visual/compound/widgets_in_dialog.html +++ b/tests/visual/compound/widgets_in_dialog.html @@ -1,31 +1,31 @@ - + Compound Visual Test : All Widgets in Dialog - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - @@ -39,21 +38,20 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 -->
    -
    -
    -
    -
    - -
    -
    -
    -
    +
    +
    +
    +
    + +
    +
    +
    +
    -
    +
    -
    -
    -
    +
    +
    diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 5c86e7887..7a9a35132 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -1,13 +1,24 @@ (function( $ ) { -function scrollTopSupport() { - $( window ).scrollTop( 1 ); - return $( window ).scrollTop() === 1; -} - -module( "position" ); +var win = $( window ), + scrollTopSupport = function() { + var support = win.scrollTop( 1 ).scrollTop() === 1; + win.scrollTop( 0 ); + scrollTopSupport = function() { + return support; + }; + return support; + }; + +module( "position", { + setup: function() { + win.scrollTop( 0 ).scrollLeft( 0 ); + } +}); test( "my, at, of", function() { + expect( 4 ); + $( "#elx" ).position({ my: "left top", at: "left top", @@ -42,6 +53,8 @@ test( "my, at, of", function() { }); test( "multiple elements", function() { + expect( 3 ); + var elements = $( "#el1, #el2" ), result = elements.position({ my: "left top", @@ -58,8 +71,9 @@ test( "multiple elements", function() { }); test( "positions", function() { - var definitions = [], - offsets = { + expect( 18 ); + + var offsets = { left: 0, center: 3, right: 6, @@ -68,33 +82,32 @@ test( "positions", function() { }, start = { left: 4, top: 4 }, el = $( "#el1" ); + $.each( [ 0, 1 ], function( my ) { $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) { $.each( [ "left", "center", "right" ], function( hindex, horizontal ) { - definitions.push({ - my: my ? horizontal + " " + vertical : "left top", - at: !my ? horizontal + " " + vertical : "left top", - result: { - top: my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ], - left: my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ] - } + var _my = my ? horizontal + " " + vertical : "left top", + _at = !my ? horizontal + " " + vertical : "left top"; + el.position({ + my: _my, + at: _at, + of: "#parent", + collision: "none" }); + deepEqual( el.offset(), { + top: start.top + offsets[ vertical ] * (my ? -1 : 1), + left: start.left + offsets[ horizontal ] * (my ? -1 : 1) + }, "Position via " + QUnit.jsDump.parse({ my: _my, at: _at }) ); }); }); }); - $.each( definitions, function( index, definition ) { - el.position({ - my: definition.my, - at: definition.at, - of: "#parent", - collision: "none" - }); - deepEqual( el.offset(), definition.result, - "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) ); - }); }); test( "of", function() { + expect( 9 + (scrollTopSupport() ? 1 : 0) ); + + var event; + $( "#elx" ).position({ my: "left top", at: "left top", @@ -141,7 +154,7 @@ test( "of", function() { left: $( document ).width() - 10 }, "document as jQuery object" ); - $( window ).scrollTop( 0 ); + win.scrollTop( 0 ); $( "#elx" ).position({ my: "right bottom", @@ -150,23 +163,23 @@ test( "of", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() - 10, - left: $( window ).width() - 10 + top: win.height() - 10, + left: win.width() - 10 }, "window" ); $( "#elx" ).position({ my: "right bottom", at: "right bottom", - of: $( window ), + of: win, collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() - 10, - left: $( window ).width() - 10 + top: win.height() - 10, + left: win.width() - 10 }, "window as jQuery object" ); if ( scrollTopSupport() ) { - $( window ).scrollTop( 500 ).scrollLeft( 200 ); + win.scrollTop( 500 ).scrollLeft( 200 ); $( "#elx" ).position({ my: "right bottom", at: "right bottom", @@ -174,13 +187,13 @@ test( "of", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() + 500 - 10, - left: $( window ).width() + 200 - 10 + top: win.height() + 500 - 10, + left: win.width() + 200 - 10 }, "window, scrolled" ); - $( window ).scrollTop( 0 ).scrollLeft( 0 ); + win.scrollTop( 0 ).scrollLeft( 0 ); } - var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); + event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); $( "#elx" ).position({ my: "left top", at: "left top", @@ -206,6 +219,8 @@ test( "of", function() { }); test( "offsets", function() { + expect( 4 ); + $( "#elx" ).position({ my: "left top", at: "left+10 bottom+10", @@ -272,7 +287,7 @@ function collisionTest( config, result, msg ) { var elem = $( "#elx" ).position( $.extend({ my: "left top", at: "right bottom", - of: window + of: "#parent" }, config ) ); deepEqual( elem.offset(), result, msg ); } @@ -284,239 +299,225 @@ function collisionTest2( config, result, msg ) { }, config ), result, msg ); } -test( "collision: fit, no offset", function() { - collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" ); +test( "collision: fit, no collision", function() { + expect( 2 ); - collisionTest2({ + collisionTest({ collision: "fit" - }, { top: 0, left: 0 }, "left top" ); -}); + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: fit, with offset", function() { collisionTest({ - collision: "fit", + collition: "fit", at: "right+2 bottom+3" - }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom"); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: fit, collision", function() { + expect( 2 + (scrollTopSupport() ? 1 : 0) ); collisionTest2({ - collision: "fit", - at: "left+2 top+3" - }, { top: 0, left: 0 }, "left top, positive offset" ); + collision: "fit" + }, { + top: 0, + left: 0 + }, "no offset" ); collisionTest2({ collision: "fit", - at: "left-2 top-3" - }, { top: 0, left: 0 }, "left top, negative offset" ); -}); + at: "left+2 top+3" + }, { + top: 0, + left: 0 + }, "with offset" ); -test( "collision: fit, window scrolled", function() { if ( scrollTopSupport() ) { - var win = $( window ); win.scrollTop( 300 ).scrollLeft( 200 ); - collisionTest({ - collision: "fit", - at: "left-100 top-100" - }, { top: 300, left: 200 }, "top left" ); - collisionTest2({ - collision: "fit", - at: "right+100 bottom+100" - }, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" ); + collision: "fit" + }, { + top: 300, + left: 200 + }, "window scrolled" ); win.scrollTop( 0 ).scrollLeft( 0 ); } }); -test( "collision: flip, no offset", function() { - collisionTest({ - collision: "flip" - }, { top: $( window ).height(), left: $( window ).width() }, "left top" ); +test( "collision: flip, no collision", function() { + expect( 2 ); - collisionTest2({ + collisionTest({ collision: "flip" - }, { top: -10, left: -10 }, "right bottom" ); -}); + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: flip, with offset", function() { collisionTest({ collision: "flip", at: "right+2 bottom+3" - }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "left top, with offset added" ); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: flip, collision", function() { + expect( 2 ); collisionTest2({ - collision: "flip", - at: "left+2 top+3" - }, { top: -7, left: -8 }, "bottom, positive offset" ); + collision: "flip" + }, { + top: 10, + left: 10 + }, "no offset" ); collisionTest2({ collision: "flip", - at: "left-2 top-3" - }, { top: -13, left: -12 }, "right bottom, negative offset" ); + at: "left+2 top+3" + }, { + top: 7, + left: 8 + }, "with offset" ); }); -test( "collision: none, no offset", function() { - collisionTest({ - collision: "none" - }, { top: $( window ).height(), left: $( window ).width() }, "left top" ); +test( "collision: none, no collision", function() { + expect( 2 ); - collisionTest2({ + collisionTest({ collision: "none" - }, { top: -10, left: -10 }, "moved to the right bottom" ); -}); + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: none, with offset", function() { collisionTest({ collision: "none", at: "right+2 bottom+3" - }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, with offset added" ); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: none, collision", function() { + expect( 2 ); collisionTest2({ - collision: "none", - at: "left+2 top+3" - }, { top: -7, left: -8 }, "left top, positive offset" ); + collision: "none" + }, { + top: -6, + left: -6 + }, "no offset" ); collisionTest2({ collision: "none", - at: "left-2 top-3" - }, { top: -13, left: -12 }, "left top, negative offset" ); + at: "left+2 top+3" + }, { + top: -3, + left: -4 + }, "with offset" ); }); test( "collision: fit, with margin", function() { - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: 10, left: 10 }, "left top" ); + expect( 2 ); $( "#elx" ).css({ - "margin-left": 5, - "margin-top": 5 + marginTop: 6, + marginLeft: 4 }); collisionTest({ collision: "fit" - }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" ); + }, { + top: 10, + left: 10 + }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: 5, left: 5 }, "left top" ); + }, { + top: 6, + left: 4 + }, "left top" ); +}); + +test( "collision: flip, with margin", function() { + expect( 3 ); $( "#elx" ).css({ - "margin-right": 15, - "margin-bottom": 15 + marginTop: 6, + marginLeft: 4 }); collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 25, left: $( window ).width() - 25 }, "right bottom" ); + collision: "flip" + }, { + top: 10, + left: 10 + }, "left top" ); collisionTest2({ - collision: "fit" - }, { top: 5, left: 5 }, "left top" ); -}); - -test( "collision: flip, with margin", function() { - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "flip", - at: "left top" - }, { top: 0, left: 0 }, "left top" ); + collision: "flip" + }, { + top: 10, + left: 10 + }, "right bottom" ); collisionTest2({ collision: "flip", - at: "right bottom" - }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" ); -}); - -test( "addClass: flipped left", function() { - var elem = $( "#elx" ).position( { - my: "left center", - of: window, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); - - elem.position({ - my: "right center", - of: window, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); -}); - -test( "addClass: flipped top", function() { - var elem = $( "#elx" ).position( { - my: "left top", - of: window, - collision: "flip", - at: "right bottom" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); - - elem.position( { - my: "left bottom", - of: window, - collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); + my: "left top" + }, { + top: 0, + left: 4 + }, "right bottom" ); }); -test( "addClass: flipped right", function() { - var elem = $( "#elx" ).position( { - my: "right center", - of: window, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); - - elem.position( { - my: "left center", - of: window, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); +test( "within", function() { + expect( 4 ); -}); - -test( "addClass: flipped bottom", function() { - var elem = $( "#elx" ).position( { - my: "left bottom", - of: window, - collision: "flip", - at: "right top" - }); + collisionTest({ + within: "#within", + collision: "fit" + }, { + top: 4, + left: 2 + }, "fit - right bottom" ); - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); + collisionTest2({ + within: "#within", + collision: "fit" + }, { + top: 2, + left: 0 + }, "fit - left top" ); - elem.position( { - my: "left top", - of: window, - collision: "flip", - at: "right bottom" - }); + collisionTest({ + within: "#within", + collision: "flip" + }, { + top: 10, + left: -6 + }, "fit - right bottom" ); - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); + collisionTest2({ + within: "#within", + collision: "flip" + }, { + top: 10, + left: -6 + }, "fit - left top" ); }); test( "fractions", function() { + expect( 1 ); + $( "#fractions-element" ).position({ my: "left top", at: "left top", @@ -527,6 +528,8 @@ test( "fractions", function() { }); test( "bug #5280: consistent results (avoid fractional values)", function() { + expect( 1 ); + var wrapper = $( "#bug-5280" ), elem = wrapper.children(), offset1 = elem.position({ diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js deleted file mode 100644 index 187408c61..000000000 --- a/tests/unit/position/position_core_within.js +++ /dev/null @@ -1,540 +0,0 @@ -(function( $ ) { - -function scrollTopSupport() { - $( window ).scrollTop( 1 ); - return $( window ).scrollTop() === 1; -} - -module( "position - within", { - setup: function(){ - $("#within-container").css({"width": "70px", "height": "70px", "top": "20px", "left": "20px", "position": "relative"}).show(); - } -}); - -var addTop = -20, - addLeft = -20; - -$.fn.addOffsets = function() { - var elOffset = this.offset(), - offset = $("#within-container").offset(); - - elOffset.top -= offset.top; - elOffset.left -= offset.left; - - return {top: elOffset.top - offset.top, left: elOffset.left - offset.left }; -}; - -test( "my, at, of", function() { - var within = $("#within-container"); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" ); - - $( "#elx" ).position({ - my: "left top", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" ); - - $( "#elx" ).position({ - my: "left", - at: "bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" ); - - $( "#elx" ).position({ - my: "left foo", - at: "bar baz", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" ); -}); - -test( "multiple elements", function() { - var elements = $( "#el1, #el2" ), - result = elements.position({ - my: "left top", - at: "left bottom", - of: "#parent", - collision: "none", - within: $("#within-container") - }), - expected = { top: addTop + 10, left: addLeft + 4 }; - - deepEqual( result, elements ); - elements.each(function() { - deepEqual( $( this ).addOffsets(), expected ); - }); -}); - -test( "positions", function() { - var definitions = [], - offsets = { - left: 0, - center: 3, - right: 6, - top: 0, - bottom: 6 - }, - start = { left: 4, top: 4 }, - el = $( "#el1" ); - $.each( [ 0, 1 ], function( my ) { - $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) { - $.each( [ "left", "center", "right" ], function( hindex, horizontal ) { - definitions.push({ - my: my ? horizontal + " " + vertical : "left top", - at: !my ? horizontal + " " + vertical : "left top", - result: { - top: addTop + (my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ]), - left: addLeft + (my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ]) - } - }); - }); - }); - }); - $.each( definitions, function( index, definition ) { - el.position({ - my: definition.my, - at: definition.at, - of: "#parent", - collision: "none", - within: $("#within-container") - }); - deepEqual( el.addOffsets(), definition.result, - "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) ); - }); -}); - -test( "of", function() { - var event, - within = $( "#within-container" ); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" ); - - $( "#elx" ).position({ - my: "left top", - at: "left bottom", - of: $( "#parentx"), - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" ); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: $( "#parentx" )[ 0 ], - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" ); - - event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: event, - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).offset(), { - top: 300, - left: 200 - }, "event - left top, left top" ); - - event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } ); - $( "#elx" ).position({ - my: "left top", - at: "right bottom", - of: event, - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).offset(), { - top: 600, - left: 400 - }, "event - left top, right bottom" ); -}); - -test( "within:offsets", function() { - var within = $("#within-container"); - - $( "#elx" ).position({ - my: "left top", - at: "left+10 bottom+10", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" ); - - $( "#elx" ).position({ - my: "left+10 top-10", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" ); - - $( "#elx" ).position({ - my: "left top", - at: "left+50% bottom-10%", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" ); - - $( "#elx" ).position({ - my: "left-30% top+50%", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" ); -}); - -test( "using", function() { - expect( 6 ); - - var within = $( "#within-container" ), - count = 0, - elems = $( "#el1, #el2" ), - expectedPosition = { top: addTop + 40, left: addLeft + 40 }, - originalPosition = elems.position({ - my: "right bottom", - at: "right bottom", - of: "#parentx", - collision: "none", - within: within - }).addOffsets(); - - elems.position({ - my: "left top", - at: "left top", - of: "#parentx", - using: function( position ) { - position.top -= within.offset().top; - position.left -= within.offset().left; - deepEqual( this, elems[ count ], "correct context for call #" + count ); - deepEqual( position, expectedPosition, "correct position for call #" + count ); - count++; - }, - within: within - }); - - elems.each(function() { - deepEqual( $( this ).addOffsets(), originalPosition, "elements not moved" ); - }); -}); - -function collisionTest( config, result, msg ) { - var within = $( "#within-container" ), - elem = $( "#elx" ).position( $.extend({ - my: "left top", - at: "right bottom", - of: "#parentx", - within: within - }, config ) ); - - deepEqual( elem.addOffsets(), result, msg ); -} - -function collisionTest2( config, result, msg ) { - collisionTest( $.extend({ - my: "right bottom", - at: "left top" - }, config ), result, msg ); -} - -test( "collision: fit, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); -}); - - -test( "collision: fit, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "fit", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( within ).width }, "right bottom"); - - collisionTest2({ - collision: "fit", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 7, left: addLeft + of.position().left - 8 }, "left top, positive offset" ); - - collisionTest2({ - collision: "fit", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, negative offset" ); -}); - -test( "collision: none, within scrolled", function() { - if ( scrollTopSupport() ) { - var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"}), - of = $("#parentx"); - within.scrollTop( 300 ).scrollLeft( 150 ); - - collisionTest({ - collision: "none", - at: "left-100 top-100" - }, { top: of.offset().top + addTop - 100 - of.height(), left: of.offset().left + addLeft - 100 - of.width() }, "top left" ); - collisionTest2({ - collision: "none", - at: "right+100 bottom+100" - }, { top: of.offset().top + addTop + 100 - 10, left: of.offset().left + addLeft + 100 - 10 }, "right bottom" ); - within.scrollTop( 0 ).scrollLeft( 0 ); - } -}); - -test( "collision: flip, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "flip" - }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); - - collisionTest2({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addTop + of.position().top - 10 }, "right bottom" ); -}); - -test( "collision: flip, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "flip", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, with offset added" ); - - collisionTest2({ - collision: "flip", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 10 + 3, left: addLeft + of.position().left - 10 + 2 }, "right bottom, positive offset" ); - - collisionTest2({ - collision: "flip", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "right bottom, negative offset" ); -}); - -test( "collision: none, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "none" - }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); - - collisionTest2({ - collision: "none" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); -}); - -test( "collision: none, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "none", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top + of.height() + 3, left: addLeft + of.position().left + of.width() + 2 }, "right bottom, with offset added" ); - - collisionTest2({ - collision: "none", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 7, left: addTop + of.position().top - 8 }, "left top, positive offset" ); - - collisionTest2({ - collision: "none", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addTop + of.position().top - 12 }, "left top, negative offset" ); -}); - -test( "collision: fit, with margin", function() { - var within = $("#within-container"), - of = $("#parentx"); - - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - $( "#elx" ).css({ - "margin-left": 5, - "margin-top": 5 - }); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( within ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - $( "#elx" ).css({ - "margin-right": 15, - "margin-bottom": 15 - }); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 15 - $.position.getScrollInfo( within ).height, left: addLeft + of.position().left + of.width() - 15 - $.position.getScrollInfo( within ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); -}); - -test( "collision: flip, with margin", function() { - var within = $("#within-container"), - of = $("#parentx"); - - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - collisionTest2({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); - - $( "#elx" ).css( "margin", 0 ); -}); - -test( "addClass: flipped left", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left center", - of: within[0], - within: within, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); - - elem.position({ - my: "right center", - of: within[0], - within: within, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); -}); - -test( "addClass: flipped top", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left top", - of: within[0], - within: within, - collision: "flip", - at: "right bottom" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); - - elem.position( { - my: "left bottom", - of: within[0], - within: within, - collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); -}); - -test( "addClass: flipped right", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "right center", - of: within[0], - within: within, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); - - elem.position( { - my: "left center", - of: within[0], - within: within, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); - -}); - -test( "addClass: flipped bottom", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left bottom", - of: window, - collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); - - elem.position( { - my: "left top", - of: window, - collision: "flip", - at: "right bottom" - }); - - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); -}); - -}( jQuery ) ); diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html index 2a7769107..8794812a8 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -33,25 +33,26 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 .height() returns the greater of the height and line-height --> -
    +
    -
    +
    -
    -
    -
    -
    +
    +
    +
    +
    -
    +
    -
    -
    -
    +
    +
    +
    -
    -
    +
    +
    +
    -- cgit v1.2.3 From 9df981d268b4029065247cf230a4e988946b7799 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 23 Apr 2012 16:07:58 -0400 Subject: Position: Added tests for flipfit. --- tests/unit/position/position_core.js | 60 ++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 7a9a35132..0ebcabef3 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -387,6 +387,44 @@ test( "collision: flip, collision", function() { }, "with offset" ); }); +test( "collision: flipfit, no collision", function() { + expect( 2 ); + + collisionTest({ + collision: "flipfit" + }, { + top: 10, + left: 10 + }, "no offset" ); + + collisionTest({ + collision: "flipfit", + at: "right+2 bottom+3" + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: flipfit, collision", function() { + expect( 2 ); + + collisionTest2({ + collision: "flipfit" + }, { + top: 10, + left: 10 + }, "no offset" ); + + collisionTest2({ + collision: "flipfit", + at: "left+2 top+3" + }, { + top: 7, + left: 8 + }, "with offset" ); +}); + test( "collision: none, no collision", function() { expect( 2 ); @@ -480,7 +518,7 @@ test( "collision: flip, with margin", function() { }); test( "within", function() { - expect( 4 ); + expect( 6 ); collisionTest({ within: "#within", @@ -504,7 +542,7 @@ test( "within", function() { }, { top: 10, left: -6 - }, "fit - right bottom" ); + }, "flip - right bottom" ); collisionTest2({ within: "#within", @@ -512,7 +550,23 @@ test( "within", function() { }, { top: 10, left: -6 - }, "fit - left top" ); + }, "flip - left top" ); + + collisionTest({ + within: "#within", + collision: "flipfit" + }, { + top: 4, + left: 0 + }, "flipfit - right bottom" ); + + collisionTest2({ + within: "#within", + collision: "flipfit" + }, { + top: 4, + left: 0 + }, "flipfit - left top" ); }); test( "fractions", function() { -- cgit v1.2.3