Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resizable: Added event tests. Confirms fix for #5817 - resize event r…

…eports unconstrained ui.size
  • Loading branch information...
commit 9a2b896744fd8ebb8318e7b0fb3f84a5d57dacc9 1 parent 38d5670
@eromba authored
Showing with 87 additions and 7 deletions.
  1. +87 −7 tests/unit/resizable/resizable_events.js
View
94 tests/unit/resizable/resizable_events.js
@@ -7,13 +7,17 @@ module("resizable: events");
test("start", function() {
- expect(1);
+ expect(5);
var count = 0,
handle = '.ui-resizable-se';
el = $("#resizable1").resizable({
handles: 'all',
start: function(event, ui) {
+ equal( ui.size.width, 100, "compare width" );
+ equal( ui.size.height, 100, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
});
@@ -26,13 +30,25 @@ test("start", function() {
test("resize", function() {
- expect(1);
+ expect(9);
var count = 0,
- handle = '.ui-resizable-e';
+ handle = '.ui-resizable-se';
el = $("#resizable1").resizable({
handles: 'all',
resize: function(event, ui) {
+ if (count === 0) {
+ equal( ui.size.width, 101, "compare width" );
+ equal( ui.size.height, 101, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
+ }
+ else {
+ equal( ui.size.width, 150, "compare width" );
+ equal( ui.size.height, 150, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
+ }
count++;
}
});
@@ -43,9 +59,65 @@ test("resize", function() {
});
+test("resize (min/max dimensions)", function() {
+
+ expect(5);
+
+ var count = 0,
+ handle = '.ui-resizable-se';
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ minWidth: 60,
+ minHeight: 60,
+ maxWidth: 100,
+ maxHeight: 100,
+ resize: function(event, ui) {
+ equal( ui.size.width, 60, "compare width" );
+ equal( ui.size.height, 60, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
+ count++;
+ }
+ });
+
+ drag(handle, -50, -50);
+
+ equal(count, 1, "resize callback should happen exactly once per size adjustment");
+
+});
+
+test("resize (containment)", function() {
+
+ expect(5);
+
+ var count = 0,
+ handle = '.ui-resizable-se',
+ container = $('#resizable1').wrap('<div>').parent().css({
+ height: '100px',
+ width: '100px'
+ });
+
+ el = $("#resizable1").resizable({
+ handles: 'all',
+ containment: container,
+ resize: function(event, ui) {
+ equal( ui.size.width, 50, "compare width" );
+ equal( ui.size.height, 50, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
+ count++;
+ }
+ });
+
+ drag(handle, -50, -50);
+
+ equal(count, 1, "resize callback should happen exactly once per size adjustment");
+
+});
+
test("resize (grid)", function() {
- expect(1);
+ expect(5);
var count = 0,
handle = '.ui-resizable-se';
@@ -53,25 +125,33 @@ test("resize (grid)", function() {
handles: 'all',
grid: 50,
resize: function(event, ui) {
+ equal( ui.size.width, 150, "compare width" );
+ equal( ui.size.height, 150, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
count++;
},
});
drag(handle, 50, 50);
- equal(count, 1, "resize callback should happen exactly once per grid-aligned size adjustment");
+ equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment");
});
test("stop", function() {
- expect(1);
+ expect(5);
var count = 0,
- handle = '.ui-resizable-e';
+ handle = '.ui-resizable-se';
el = $("#resizable1").resizable({
handles: 'all',
stop: function(event, ui) {
+ equal( ui.size.width, 150, "compare width" );
+ equal( ui.size.height, 150, "compare height" );
+ equal( ui.originalSize.width, 100, "compare original width" );
+ equal( ui.originalSize.height, 100, "compare original height" );
count++;
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.