diff options
author | Richard Worth <rdworth@gmail.com> | 2009-02-04 04:47:39 +0000 |
---|---|---|
committer | Richard Worth <rdworth@gmail.com> | 2009-02-04 04:47:39 +0000 |
commit | 96b1534483a7f5557e0c6cc795ae90faed44c22d (patch) | |
tree | 4cf0eb4943c6b5319ab6cc30add5abca29b73084 | |
parent | 04b304031193ff08f2aaac61ce65fefef025adea (diff) | |
download | jquery-ui-96b1534483a7f5557e0c6cc795ae90faed44c22d.tar.gz jquery-ui-96b1534483a7f5557e0c6cc795ae90faed44c22d.zip |
resizable unit tests: split tests into individual files
-rw-r--r-- | tests/unit/resizable/resizable.html | 7 | ||||
-rw-r--r-- | tests/unit/resizable/resizable.js | 415 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_core.js | 140 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_defaults.js | 26 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_events.js | 10 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_methods.js | 54 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_options.js | 182 | ||||
-rw-r--r-- | tests/unit/resizable/resizable_tickets.js | 4 |
8 files changed, 411 insertions, 427 deletions
diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 037e7ee4f..b63495f9a 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -12,7 +12,12 @@ <script type="text/javascript" src="../../../external/qunit/testrunner.js"></script> <script type="text/javascript" src="../../../external/simulate/jquery.simulate.js"></script> - <script type="text/javascript" src="resizable.js"></script> + <script type="text/javascript" src="resizable_core.js"></script> + <script type="text/javascript" src="resizable_defaults.js"></script> + <script type="text/javascript" src="resizable_events.js"></script> + <script type="text/javascript" src="resizable_methods.js"></script> + <script type="text/javascript" src="resizable_options.js"></script> + <script type="text/javascript" src="resizable_tickets.js"></script> </head> <body> diff --git a/tests/unit/resizable/resizable.js b/tests/unit/resizable/resizable.js deleted file mode 100644 index 260e923b1..000000000 --- a/tests/unit/resizable/resizable.js +++ /dev/null @@ -1,415 +0,0 @@ -/* - * resizable tests - */ -(function($) { -// -// Resizable Test Helper Functions -// - -var defaults = { - animate: false, - animateDuration: 'slow', - animateEasing: 'swing', - alsoResize: false, - aspectRatio: false, - autoHide: false, - cancel: ':input,option', - containment: false, - delay: 0, - disabled: false, - disableSelection: true, - distance: 1, - ghost: false, - grid: false, - handles: 'e,s,se', - helper: false, - maxHeight: null, - maxWidth: null, - minHeight: 10, - minWidth: 10, - preserveCursor: true, - preventDefault: true, - proportionallyResize: false, - transparent: false -}; - -var drag = function(el, dx, dy, complete) { - - // speed = sync -> Drag syncrhonously. - // speed = fast|slow -> Drag asyncrhonously - animated. - - //this mouseover is to work around a limitation in resizable - //TODO: fix resizable so handle doesn't require mouseover in order to be used - $(el).simulate("mouseover"); - - return $(el).simulate("drag", { - dx: dx||0, dy: dy||0, speed: 'sync', complete: complete - }); -}; - -// Resizable Tests -module("resizable"); - -test("init", function() { - expect(6); - - $("<div></div>").appendTo('body').resizable().remove(); - ok(true, '.resizable() called on element'); - - $([]).resizable().remove(); - ok(true, '.resizable() called on empty collection'); - - $('<div></div>').resizable().remove(); - ok(true, '.resizable() called on disconnected DOMElement'); - - $('<div></div>').resizable().resizable("foo").remove(); - ok(true, 'arbitrary method called after init'); - - el = $('<div></div>').resizable() - var foo = el.data("foo.resizable"); - el.remove(); - ok(true, 'arbitrary option getter after init'); - - $('<div></div>').resizable().data("foo.resizable", "bar").remove(); - ok(true, 'arbitrary option setter after init'); -}); - -test("destroy", function() { - expect(6); - - $("<div></div>").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'); - - $('<div></div>').resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on disconnected DOMElement'); - - $('<div></div>').resizable().resizable("destroy").resizable("foo").remove(); - ok(true, 'arbitrary method called after destroy'); - - el = $('<div></div>').resizable(); - var foo = el.resizable("destroy").data("foo.resizable"); - el.remove(); - ok(true, 'arbitrary option getter after destroy'); - - $('<div></div>').resizable().resizable("destroy").data("foo.resizable", "bar").remove(); - ok(true, 'arbitrary option setter after destroy'); -}); - -test("element types", function() { - var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' - + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' - + ',acronym,code,samp,kbd,var,img,object,hr' - + ',input,button,label,select,iframe').split(','); - - $.each(typeNames, function(i) { - var typeName = typeNames[i]; - el = $(document.createElement(typeName)).appendTo('body'); - (typeName == 'table' && el.append("<tr><td>content</td></tr>")); - el.resizable(); - ok(true, '$("<' + typeName + '/>").resizable()'); - el.resizable("destroy"); - el.remove(); - }); -}); - -test("defaults", function() { - el = $('<div></div>').resizable(); - $.each(defaults, function(key, val) { - var actual = el.data(key + ".resizable"), expected = val; - same(actual, expected, key); - }); - el.remove(); -}); - -test("n", function() { - expect(2); - - var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, 0, -50); - equals( target.height(), 150, "compare height" ); - - drag(handle, 0, 50); - equals( target.height(), 100, "compare height" ); -}); - -test("s", function() { - expect(2); - - var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, 0, 50); - equals( target.height(), 150, "compare height" ); - - drag(handle, 0, -50); - equals( target.height(), 100, "compare height" ); -}); - -test("e", function() { - expect(2); - - var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, 50); - equals( target.width(), 150, "compare width"); - - drag(handle, -50); - equals( target.width(), 100, "compare width" ); -}); - -test("w", function() { - expect(2); - - var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, -50); - equals( target.width(), 150, "compare width" ); - - drag(handle, 50); - equals( target.width(), 100, "compare width" ); -}); - -test("ne", function() { - expect(4); - - var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' }); - - drag(handle, -50, -50); - equals( target.width(), 50, "compare width" ); - equals( target.height(), 150, "compare height" ); - - drag(handle, 50, 50); - equals( target.width(), 100, "compare width" ); - equals( target.height(), 100, "compare height" ); -}); - -test("se", function() { - expect(4); - - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, 50, 50); - equals( target.width(), 150, "compare width" ); - equals( target.height(), 150, "compare height" ); - - drag(handle, -50, -50); - equals( target.width(), 100, "compare width" ); - equals( target.height(), 100, "compare height" ); -}); - -test("sw", function() { - expect(4); - - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, -50, -50); - equals( target.width(), 150, "compare width" ); - equals( target.height(), 50, "compare height" ); - - drag(handle, 50, 50); - equals( target.width(), 100, "compare width" ); - equals( target.height(), 100, "compare height" ); -}); - -test("nw", function() { - expect(4); - - var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' }); - - drag(handle, -50, -50); - equals( target.width(), 150, "compare width" ); - equals( target.height(), 150, "compare height" ); - - drag(handle, 50, 50); - equals( target.width(), 100, "compare width" ); - equals( target.height(), 100, "compare height" ); -}); - -module("resizable: Options"); - -test("aspectRatio: 'preserve' (e)", function() { - expect(4); - - var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, 80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, -130); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (w)", function() { - expect(4); - - var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, -80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, 130); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (n)", function() { - expect(4); - - var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, 0, -80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, 0, 80); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (s)", function() { - expect(4); - - var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, 0, 80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, 0, -80); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (se)", function() { - expect(4); - - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, 80, 80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, -80, -80); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (sw)", function() { - expect(4); - - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, -80, 80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, 80, -80); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("aspectRatio: 'preserve' (ne)", function() { - expect(4); - - var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); - - drag(handle, 80, -80); - equals( target.width(), 130, "compare maxWidth"); - equals( target.height(), 130, "compare maxHeight"); - - drag(handle, -80, 80); - equals( target.width(), 70, "compare minWidth"); - equals( target.height(), 70, "compare minHeight"); -}); - -test("grid", function() { - expect(4); - - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] }); - - drag(handle, 3, 9); - equals( target.width(), 103, "compare width"); - equals( target.height(), 100, "compare height"); - - drag(handle, 15, 11); - equals( target.width(), 118, "compare width"); - equals( target.height(), 120, "compare height"); -}); - -test("grid (wrapped)", function() { - expect(4); - - var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] }); - - drag(handle, 3, 9); - equals( target.width(), 103, "compare width"); - equals( target.height(), 100, "compare height"); - - drag(handle, 15, 11); - equals( target.width(), 118, "compare width"); - equals( target.height(), 120, "compare height"); -}); - -test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect(4); - - var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); - - drag(handle, -50, -50); - equals( target.width(), 60, "compare minWidth" ); - equals( target.height(), 60, "compare minHeight" ); - - drag(handle, 70, 70); - equals( target.width(), 100, "compare maxWidth" ); - equals( target.height(), 100, "compare maxHeight" ); -}); - -test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect(4); - - var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); - - drag(handle, 50, -50); - equals( target.width(), 60, "compare minWidth" ); - equals( target.height(), 60, "compare minHeight" ); - - drag(handle, -70, 70); - equals( target.width(), 100, "compare maxWidth" ); - equals( target.height(), 100, "compare maxHeight" ); -}); - -test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect(4); - - var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); - - drag(handle, -50, 50); - equals( target.width(), 60, "compare minWidth" ); - equals( target.height(), 60, "compare minHeight" ); - - drag(handle, 70, -70); - equals( target.width(), 100, "compare maxWidth" ); - equals( target.height(), 100, "compare maxHeight" ); -}); - -test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect(4); - - var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); - - drag(handle, 70, 70); - equals( target.width(), 60, "compare minWidth" ); - equals( target.height(), 60, "compare minHeight" ); - - drag(handle, -70, -70); - equals( target.width(), 100, "compare maxWidth" ); - equals( target.height(), 100, "compare maxHeight" ); -}); - -})(jQuery); diff --git a/tests/unit/resizable/resizable_core.js b/tests/unit/resizable/resizable_core.js index bc9b62650..33a3f723b 100644 --- a/tests/unit/resizable/resizable_core.js +++ b/tests/unit/resizable/resizable_core.js @@ -1,12 +1,148 @@ /* * resizable_core.js */ + +var el; + +var drag = function(el, dx, dy, complete) { + + // speed = sync -> Drag syncrhonously. + // speed = fast|slow -> Drag asyncrhonously - animated. + + //this mouseover is to work around a limitation in resizable + //TODO: fix resizable so handle doesn't require mouseover in order to be used + $(el).simulate("mouseover"); + + return $(el).simulate("drag", { + dx: dx||0, dy: dy||0, speed: 'sync', complete: complete + }); +}; + (function($) { module("resizable: core"); -test("testname", function() { - ok(false, "missing test - untested code is broken code."); +/* +test("element types", function() { + var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' + + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' + + ',acronym,code,samp,kbd,var,img,object,hr' + + ',input,button,label,select,iframe').split(','); + + $.each(typeNames, function(i) { + var typeName = typeNames[i]; + el = $(document.createElement(typeName)).appendTo('body'); + (typeName == 'table' && el.append("<tr><td>content</td></tr>")); + el.resizable(); + ok(true, '$("<' + typeName + '/>").resizable()'); + el.resizable("destroy"); + el.remove(); + }); +}); +*/ + +test("n", function() { + expect(2); + + var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 0, -50); + equals( target.height(), 150, "compare height" ); + + drag(handle, 0, 50); + equals( target.height(), 100, "compare height" ); +}); + +test("s", function() { + expect(2); + + var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 0, 50); + equals( target.height(), 150, "compare height" ); + + drag(handle, 0, -50); + equals( target.height(), 100, "compare height" ); +}); + +test("e", function() { + expect(2); + + var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 50); + equals( target.width(), 150, "compare width"); + + drag(handle, -50); + equals( target.width(), 100, "compare width" ); +}); + +test("w", function() { + expect(2); + + var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50); + equals( target.width(), 150, "compare width" ); + + drag(handle, 50); + equals( target.width(), 100, "compare width" ); +}); + +test("ne", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 50, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("se", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, 50, 50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, -50, -50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("sw", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 50, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); +}); + +test("nw", function() { + expect(4); + + var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' }); + + drag(handle, -50, -50); + equals( target.width(), 150, "compare width" ); + equals( target.height(), 150, "compare height" ); + + drag(handle, 50, 50); + equals( target.width(), 100, "compare width" ); + equals( target.height(), 100, "compare height" ); }); })(jQuery); diff --git a/tests/unit/resizable/resizable_defaults.js b/tests/unit/resizable/resizable_defaults.js index 256f6fdec..124aa336b 100644 --- a/tests/unit/resizable/resizable_defaults.js +++ b/tests/unit/resizable/resizable_defaults.js @@ -3,7 +3,31 @@ */ var resizable_defaults = { - disabled: false + animate: false, + animateDuration: 'slow', + animateEasing: 'swing', + alsoResize: false, + aspectRatio: false, + autoHide: false, + cancel: ':input,option', + containment: false, + delay: 0, + disabled: false, + disableSelection: true, + distance: 1, + ghost: false, + grid: false, + handles: 'e,s,se', + helper: false, + maxHeight: null, + maxWidth: null, + minHeight: 10, + minWidth: 10, + preserveCursor: true, + preventDefault: true, + proportionallyResize: false, + transparent: false, + zIndex: 1001 }; commonWidgetTests('resizable', { defaults: resizable_defaults }); diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js index 0395a55e7..e8041f064 100644 --- a/tests/unit/resizable/resizable_events.js +++ b/tests/unit/resizable/resizable_events.js @@ -5,7 +5,15 @@ module("resizable: events"); -test("testname", function() { +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."); }); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index b5703cde6..43d573387 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -5,7 +5,59 @@ module("resizable: methods"); -test("testname", function() { +test("init", function() { + expect(6); + + $("<div></div>").appendTo('body').resizable().remove(); + ok(true, '.resizable() called on element'); + + $([]).resizable().remove(); + ok(true, '.resizable() called on empty collection'); + + $('<div></div>').resizable().remove(); + ok(true, '.resizable() called on disconnected DOMElement'); + + $('<div></div>').resizable().resizable("foo").remove(); + ok(true, 'arbitrary method called after init'); + + el = $('<div></div>').resizable() + var foo = el.data("foo.resizable"); + el.remove(); + ok(true, 'arbitrary option getter after init'); + + $('<div></div>').resizable().data("foo.resizable", "bar").remove(); + ok(true, 'arbitrary option setter after init'); +}); + +test("destroy", function() { + expect(6); + + $("<div></div>").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'); + + $('<div></div>').resizable().resizable("destroy").remove(); + ok(true, '.resizable("destroy") called on disconnected DOMElement'); + + $('<div></div>').resizable().resizable("destroy").resizable("foo").remove(); + ok(true, 'arbitrary method called after destroy'); + + el = $('<div></div>').resizable(); + var foo = el.resizable("destroy").data("foo.resizable"); + el.remove(); + ok(true, 'arbitrary option getter after destroy'); + + $('<div></div>').resizable().resizable("destroy").data("foo.resizable", "bar").remove(); + ok(true, 'arbitrary option setter after destroy'); +}); + +test("enable", function() { + ok(false, "missing test - untested code is broken code."); +}); + +test("disable", function() { ok(false, "missing test - untested code is broken code."); }); diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index f45d06f04..389931f92 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -5,8 +5,186 @@ module("resizable: options"); -test("testname", function() { - ok(false, "missing test - untested code is broken code."); +test("aspectRatio: 'preserve' (e)", function() { + expect(4); + + var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -130); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (w)", function() { + expect(4); + + var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 130); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (n)", function() { + expect(4); + + var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 0, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 0, 80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (s)", function() { + expect(4); + + var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 0, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 0, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (se)", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -80, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (sw)", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, -80, 80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, 80, -80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("aspectRatio: 'preserve' (ne)", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); + + drag(handle, 80, -80); + equals( target.width(), 130, "compare maxWidth"); + equals( target.height(), 130, "compare maxHeight"); + + drag(handle, -80, 80); + equals( target.width(), 70, "compare minWidth"); + equals( target.height(), 70, "compare minHeight"); +}); + +test("grid", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] }); + + drag(handle, 3, 9); + equals( target.width(), 103, "compare width"); + equals( target.height(), 100, "compare height"); + + drag(handle, 15, 11); + equals( target.width(), 118, "compare width"); + equals( target.height(), 120, "compare height"); +}); + +test("grid (wrapped)", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] }); + + drag(handle, 3, 9); + equals( target.width(), 103, "compare width"); + equals( target.height(), 100, "compare height"); + + drag(handle, 15, 11); + equals( target.width(), 118, "compare width"); + equals( target.height(), 120, "compare height"); +}); + +test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, -50, -50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, 70, 70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, 50, -50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, -70, 70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, -50, 50); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, 70, -70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); +}); + +test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { + expect(4); + + var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); + + drag(handle, 70, 70); + equals( target.width(), 60, "compare minWidth" ); + equals( target.height(), 60, "compare minHeight" ); + + drag(handle, -70, -70); + equals( target.width(), 100, "compare maxWidth" ); + equals( target.height(), 100, "compare maxHeight" ); }); })(jQuery); diff --git a/tests/unit/resizable/resizable_tickets.js b/tests/unit/resizable/resizable_tickets.js index 73ee57359..55486655c 100644 --- a/tests/unit/resizable/resizable_tickets.js +++ b/tests/unit/resizable/resizable_tickets.js @@ -5,8 +5,4 @@ module("resizable: tickets"); -test("testname", function() { - ok(false, "missing test - untested code is broken code."); -}); - })(jQuery); |