diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-10-30 21:50:08 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-10-30 22:19:55 -0400 |
commit | b49e071d39795255e88b13ae172367201484c352 (patch) | |
tree | 4df1090ad188613efe93f4c54949fcd1b66716bf /tests | |
parent | f0daa220d67968f61c42e378b10fcb41687cd215 (diff) | |
download | jquery-ui-b49e071d39795255e88b13ae172367201484c352.tar.gz jquery-ui-b49e071d39795255e88b13ae172367201484c352.zip |
Dev: Standardized the selectable test suite. Fixed #8752 - Dev: Get selectable test suite to pass
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/all-active.html | 2 | ||||
-rw-r--r-- | tests/unit/all.html | 2 | ||||
-rw-r--r-- | tests/unit/selectable/selectable_common.js | 1 | ||||
-rw-r--r-- | tests/unit/selectable/selectable_core.js | 24 | ||||
-rw-r--r-- | tests/unit/selectable/selectable_events.js | 4 | ||||
-rw-r--r-- | tests/unit/selectable/selectable_methods.js | 20 | ||||
-rw-r--r-- | tests/unit/selectable/selectable_options.js | 25 |
7 files changed, 40 insertions, 38 deletions
diff --git a/tests/unit/all-active.html b/tests/unit/all-active.html index 200a6a53d..350aca7b9 100644 --- a/tests/unit/all-active.html +++ b/tests/unit/all-active.html @@ -29,7 +29,7 @@ "position/position.html", "progressbar/progressbar.html", //"resizable/resizable.html", - //"selectable/selectable.html", + "selectable/selectable.html", //"slider/slider.html", //"sortable/sortable.html", "spinner/spinner.html", diff --git a/tests/unit/all.html b/tests/unit/all.html index 8020e2686..e37878c1c 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -29,7 +29,7 @@ "position/position.html", "progressbar/progressbar.html", //"resizable/resizable.html", - //"selectable/selectable.html", + "selectable/selectable.html", "slider/slider.html", //"sortable/sortable.html", "spinner/spinner.html", diff --git a/tests/unit/selectable/selectable_common.js b/tests/unit/selectable/selectable_common.js index 885e79401..aee6a15ac 100644 --- a/tests/unit/selectable/selectable_common.js +++ b/tests/unit/selectable/selectable_common.js @@ -3,6 +3,7 @@ TestHelpers.commonWidgetTests('selectable', { appendTo: 'body', autoRefresh: true, cancel: 'input,textarea,button,select,option', + create: null, delay: 0, disabled: false, distance: 0, diff --git a/tests/unit/selectable/selectable_core.js b/tests/unit/selectable/selectable_core.js index d2e885fc7..de89e66a7 100644 --- a/tests/unit/selectable/selectable_core.js +++ b/tests/unit/selectable/selectable_core.js @@ -2,15 +2,15 @@ * selectable_core.js */ -var el; - -TestHelpers.selectableDrag = function drag(dx, dy) { - var off = el.offset(), pos = { clientX: off.left, clientY: off.top }; - el.simulate("mousedown", pos); - $(document).simulate("mousemove", pos); - pos.clientX += dx; - pos.clientY += dy; - $(document).simulate("mousemove", pos); - $(document).simulate("mouseup", pos); -}; - +TestHelpers.selectable = { + drag: function drag(el, dx, dy) { + var off = el.offset(), + pos = { clientX: off.left, clientY: off.top }; + el.simulate("mousedown", pos); + $(document).simulate("mousemove", pos); + pos.clientX += dx; + pos.clientY += dy; + $(document).simulate("mousemove", pos); + $(document).simulate("mouseup", pos); + } +};
\ No newline at end of file diff --git a/tests/unit/selectable/selectable_events.js b/tests/unit/selectable/selectable_events.js index bfd431bd8..331bae146 100644 --- a/tests/unit/selectable/selectable_events.js +++ b/tests/unit/selectable/selectable_events.js @@ -7,7 +7,7 @@ module("selectable: events"); test("start", function() { expect(2); - el = $("#selectable1"); + var el = $("#selectable1"); el.selectable({ start: function() { ok(true, "drag fired start callback"); @@ -19,7 +19,7 @@ test("start", function() { test("stop", function() { expect(2); - el = $("#selectable1"); + var el = $("#selectable1"); el.selectable({ start: function() { ok(true, "drag fired stop callback"); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index ee7242d9b..aa8924176 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -6,7 +6,7 @@ module("selectable: methods"); test("init", function() { - expect(6); + expect( 5 ); $("<div></div>").appendTo('body').selectable().remove(); ok(true, '.selectable() called on element'); @@ -17,10 +17,7 @@ test("init", function() { $("<div></div>").selectable().remove(); ok(true, '.selectable() called on disconnected DOMElement'); - $("<div></div>").selectable().selectable("foo").remove(); - ok(true, 'arbitrary method called after init'); - - el = $("<div></div>").selectable(); + var el = $("<div></div>").selectable(); el.selectable("option", "foo"); el.remove(); ok(true, 'arbitrary option getter after init'); @@ -30,6 +27,8 @@ test("init", function() { }); test("destroy", function() { + expect( 4 ); + $("<div></div>").appendTo('body').selectable().selectable("destroy").remove(); ok(true, '.selectable("destroy") called on element'); @@ -39,9 +38,6 @@ test("destroy", function() { $("<div></div>").selectable().selectable("destroy").remove(); ok(true, '.selectable("destroy") called on disconnected DOMElement'); - $("<div></div>").selectable().selectable("destroy").selectable("foo").remove(); - ok(true, 'arbitrary method called after destroy'); - var expected = $('<div></div>').selectable(), actual = expected.selectable('destroy'); equal(actual, expected, 'destroy is chainable'); @@ -50,9 +46,9 @@ test("destroy", function() { test("enable", function() { expect(3); var expected, actual, - fired = false; + fired = false, + el = $("#selectable1"); - el = $("#selectable1"); el.selectable({ disabled: true, start: function() { fired = true; } @@ -72,9 +68,9 @@ test("enable", function() { test("disable", function() { expect(3); var expected, actual, - fired = false; + fired = false, + el = $("#selectable1"); - el = $("#selectable1"); el.selectable({ disabled: false, start: function() { fired = true; } diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js index ad57000a9..2b7fc1648 100644 --- a/tests/unit/selectable/selectable_options.js +++ b/tests/unit/selectable/selectable_options.js @@ -7,13 +7,15 @@ module("selectable: options"); test("autoRefresh", function() { expect(3); - el = $("#selectable1"); - var actual, sel = $("*", el), selected = function() { actual += 1; }; - actual = 0; + var actual = 0, + el = $("#selectable1"), + sel = $("*", el), + selected = function() { actual += 1; }; + el = $("#selectable1").selectable({ autoRefresh: false, selected: selected }); sel.hide(); - TestHelpers.selectableDrag(1000, 1000); + TestHelpers.selectable.drag(el, 1000, 1000); equal(actual, sel.length); el.selectable("destroy"); @@ -21,10 +23,10 @@ test("autoRefresh", function() { sel.show(); el = $("#selectable1").selectable({ autoRefresh: true, selected: selected }); sel.hide(); - TestHelpers.selectableDrag(1000, 1000); + TestHelpers.selectable.drag(el, 1000, 1000); equal(actual, 0); sel.show(); - TestHelpers.selectableDrag(1000, 1000); + TestHelpers.selectable.drag(el, 1000, 1000); equal(actual, sel.length); el.selectable("destroy"); sel.show(); @@ -32,12 +34,15 @@ test("autoRefresh", function() { test("filter", function() { expect(2); - el = $("#selectable1"); - var actual, sel = $("*", el), selected = function() { actual += 1; }; - actual = 0; + var actual =0, + el = $("#selectable1"), + sel = $("*", el), + selected = function() { actual += 1; }; + + el = $("#selectable1").selectable({ filter: '.special', selected: selected }); - TestHelpers.selectableDrag(1000, 1000); + TestHelpers.selectable.drag(el, 1000, 1000); ok(sel.length !== 1, "this test assumes more than 1 selectee"); equal(actual, 1); el.selectable("destroy"); |