diff options
author | Scott González <scott.gonzalez@gmail.com> | 2015-04-07 10:30:07 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2015-04-09 09:26:58 -0400 |
commit | dc4b015a8b9acdb5bff2d5dd89737b3d8b64097f (patch) | |
tree | f2dc9ecccc32b33622aef1e597992e5a668efe56 /tests/unit/dialog | |
parent | 42566bdd037ac57cf7d6d7a5d059db2ba42518d9 (diff) | |
download | jquery-ui-dc4b015a8b9acdb5bff2d5dd89737b3d8b64097f.tar.gz jquery-ui-dc4b015a8b9acdb5bff2d5dd89737b3d8b64097f.zip |
Tests: Widget test helpers extend the main helper
Ref #10119
Ref gh-1528
Diffstat (limited to 'tests/unit/dialog')
-rw-r--r-- | tests/unit/dialog/dialog_events.js | 14 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_options.js | 50 | ||||
-rw-r--r-- | tests/unit/dialog/dialog_test_helpers.js | 16 |
3 files changed, 41 insertions, 39 deletions
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index a6e4c0501..cc5bef8fa 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -2,7 +2,7 @@ define( [ "jquery", "./dialog_test_helpers", "ui/dialog" -], function( $, dialogTestHelpers ) { +], function( $, testHelper ) { module("dialog: events"); @@ -104,7 +104,7 @@ test("dragStart", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -132,7 +132,7 @@ test("drag", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -156,7 +156,7 @@ test("dragStop", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -184,7 +184,7 @@ test("resizeStart", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -216,7 +216,7 @@ test("resize", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -244,7 +244,7 @@ test("resizeStop", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index e4ff6ac72..1b9af7a09 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -4,7 +4,7 @@ define( [ "ui/dialog", "ui/effect-blind", "ui/effect-explode" -], function( $, dialogTestHelpers ) { +], function( $, testHelper ) { module("dialog: options"); @@ -231,15 +231,15 @@ test("draggable", function() { var element = $("<div></div>").dialog({ draggable: false }); - dialogTestHelpers.testDrag(element, 50, -50, 0, 0); + testHelper.testDrag(element, 50, -50, 0, 0); element.dialog("option", "draggable", true); - dialogTestHelpers.testDrag(element, 50, -50, 50, -50); + testHelper.testDrag(element, 50, -50, 50, -50); element.remove(); element = $("<div></div>").dialog({ draggable: true }); - dialogTestHelpers.testDrag(element, 50, -50, 50, -50); + testHelper.testDrag(element, 50, -50, 50, -50); element.dialog("option", "draggable", false); - dialogTestHelpers.testDrag(element, 50, -50, 0, 0); + testHelper.testDrag(element, 50, -50, 0, 0); element.remove(); }); @@ -269,17 +269,17 @@ test("maxHeight", function( assert ) { expect(3); var element = $("<div></div>").dialog({ maxHeight: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000); + testHelper.drag(element, ".ui-resizable-s", 1000, 1000); assert.close(element.dialog("widget").height(), 200, 1, "maxHeight"); element.remove(); element = $("<div></div>").dialog({ maxHeight: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-n", -1000, -1000); + testHelper.drag(element, ".ui-resizable-n", -1000, -1000); assert.close(element.dialog("widget").height(), 200, 1, "maxHeight"); element.remove(); element = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); - dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000); + testHelper.drag(element, ".ui-resizable-s", 1000, 1000); assert.close(element.dialog("widget").height(), 300, 1, "maxHeight"); element.remove(); }); @@ -288,17 +288,17 @@ test("maxWidth", function( assert ) { expect(3); var element = $("<div></div>").dialog({ maxWidth: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-e", 1000, 1000); + testHelper.drag(element, ".ui-resizable-e", 1000, 1000); assert.close(element.dialog("widget").width(), 200, 1, "maxWidth"); element.remove(); element = $("<div></div>").dialog({ maxWidth: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000); + testHelper.drag(element, ".ui-resizable-w", -1000, -1000); assert.close(element.dialog("widget").width(), 200, 1, "maxWidth"); element.remove(); element = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); - dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000); + testHelper.drag(element, ".ui-resizable-w", -1000, -1000); assert.close(element.dialog("widget").width(), 300, 1, "maxWidth"); element.remove(); }); @@ -307,17 +307,17 @@ test("minHeight", function( assert ) { expect(3); var element = $("<div></div>").dialog({ minHeight: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-s", -1000, -1000); + testHelper.drag(element, ".ui-resizable-s", -1000, -1000); assert.close(element.dialog("widget").height(), 10, 1, "minHeight"); element.remove(); element = $("<div></div>").dialog({ minHeight: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000); + testHelper.drag(element, ".ui-resizable-n", 1000, 1000); assert.close(element.dialog("widget").height(), 10, 1, "minHeight"); element.remove(); element = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); - dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000); + testHelper.drag(element, ".ui-resizable-n", 1000, 1000); assert.close(element.dialog("widget").height(), 30, 1, "minHeight"); element.remove(); }); @@ -326,17 +326,17 @@ test("minWidth", function( assert ) { expect(3); var element = $("<div></div>").dialog({ minWidth: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-e", -1000, -1000); + testHelper.drag(element, ".ui-resizable-e", -1000, -1000); assert.close(element.dialog("widget").width(), 10, 1, "minWidth"); element.remove(); element = $("<div></div>").dialog({ minWidth: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000); + testHelper.drag(element, ".ui-resizable-w", 1000, 1000); assert.close(element.dialog("widget").width(), 10, 1, "minWidth"); element.remove(); element = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); - dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000); + testHelper.drag(element, ".ui-resizable-w", 1000, 1000); assert.close(element.dialog("widget").width(), 30, 1, "minWidth"); element.remove(); }); @@ -424,15 +424,15 @@ test("resizable", function() { expect(4); var element = $("<div></div>").dialog(); - dialogTestHelpers.shouldResize(element, 50, 50, "[default]"); + testHelper.shouldResize(element, 50, 50, "[default]"); element.dialog("option", "resizable", false); - dialogTestHelpers.shouldResize(element, 0, 0, "disabled after init"); + testHelper.shouldResize(element, 0, 0, "disabled after init"); element.remove(); element = $("<div></div>").dialog({ resizable: false }); - dialogTestHelpers.shouldResize(element, 0, 0, "disabled in init options"); + testHelper.shouldResize(element, 0, 0, "disabled in init options"); element.dialog("option", "resizable", true); - dialogTestHelpers.shouldResize(element, 50, 50, "enabled after init"); + testHelper.shouldResize(element, 50, 50, "enabled after init"); element.remove(); }); @@ -497,18 +497,18 @@ test("#4826: setting resizable false toggles resizable on dialog", function() { var i, element = $("<div></div>").dialog({ resizable: false }); - dialogTestHelpers.shouldResize(element, 0, 0, "[default]"); + testHelper.shouldResize(element, 0, 0, "[default]"); for (i=0; i<2; i++) { element.dialog("close").dialog("open"); - dialogTestHelpers.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); + testHelper.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); } element.remove(); element = $("<div></div>").dialog({ resizable: true }); - dialogTestHelpers.shouldResize(element, 50, 50, "[default]"); + testHelper.shouldResize(element, 50, 50, "[default]"); for (i=0; i<2; i++) { element.dialog("close").dialog("option", "resizable", false).dialog("open"); - dialogTestHelpers.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); + testHelper.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); } element.remove(); diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index f11c77cde..f84d1d624 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -1,6 +1,10 @@ -define( function() { +define( [ + "jquery", + "lib/helper", + "ui/dialog" +], function( $, helper ) { -var dialogTestHelpers = { +return $.extend( helper, { drag: function(element, handle, dx, dy) { var d = element.dialog("widget"); //this mouseover is to work around a limitation in resizable @@ -16,7 +20,7 @@ var dialogTestHelpers = { handle = $(".ui-dialog-titlebar", d), offsetBefore = d.offset(); - dialogTestHelpers.drag(element, handle, dx, dy); + this.drag(element, handle, dx, dy); offsetAfter = d.offset(); @@ -36,7 +40,7 @@ var dialogTestHelpers = { heightBefore = element.height(), widthBefore = element.width(); - dialogTestHelpers.drag(element, handle, 50, 50); + this.drag(element, handle, 50, 50); heightAfter = element.height(); widthAfter = element.width(); @@ -46,8 +50,6 @@ var dialogTestHelpers = { expected = { width: widthBefore + dw, height: heightBefore + dh }; deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg); } -}; - -return dialogTestHelpers; +} ); } ); |