Skip to content
Browse files

added more $.param.sorted unit tests

  • Loading branch information...
1 parent 6c6bade commit aa12c92168fe92d051d24c9ab4249286108a692b @cowboy cowboy committed Aug 20, 2010
Showing with 52 additions and 4 deletions.
  1. +4 −3 README.markdown
  2. +1 −1 docs/nd/Data/FileInfo.nd
  3. BIN docs/nd/Data/SymbolTable.nd
  4. +47 −0 unit/unit.js
View
7 README.markdown
@@ -1,7 +1,7 @@
# jQuery BBQ: Back Button & Query Library #
[http://benalman.com/projects/jquery-bbq-plugin/](http://benalman.com/projects/jquery-bbq-plugin/)
-Version: 1.2.1, Last updated: 2/17/2010
+Version: 1.3pre, Last updated: 8/20/2010
jQuery BBQ enables simple, yet powerful bookmarkable #hash history via a cross-browser window.onhashchange event. In addition, jQuery BBQ provides a full jQuery.deparam() method, along with both fragment and query string parse and merge utility methods.
@@ -27,10 +27,10 @@ tested with, what browsers it has been tested in, and where the unit tests
reside (so you can test it yourself).
### jQuery Versions ###
-1.3.2, 1.4.1, 1.4.2
+1.2.6, 1.3.2, 1.4.1, 1.4.2
### Browsers Tested ###
-Internet Explorer 6-8, Firefox 2-3.7, Safari 3-4, Chrome 4-5, Opera 9.6-10.1.
+Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
### Unit Tests ###
[http://benalman.com/code/projects/jquery-bbq/unit/](http://benalman.com/code/projects/jquery-bbq/unit/)
@@ -54,6 +54,7 @@ Safari: Back Button from a different domain
## Release History ##
+1.3pre - (8/20/2010) Integrated jQuery hashchange event v1.3, which adds document.title and document.domain support in IE6/7, BlackBerry support, better Iframe hiding for accessibility reasons, and the new jQuery.fn.hashchange "shortcut" method. Added the jQuery.param.sorted method which reduces the possibility of extraneous hashchange event triggering.
1.2.1 - (2/17/2010) Actually fixed the stale window.location Safari bug from jQuery hashchange event in BBQ, which was the main reason for the previous release!
1.2 - (2/16/2010) Integrated jQuery hashchange event v1.2, which fixes a Safari bug, the event can now be bound before DOM ready, and IE6/7 page should no longer scroll when the event is first bound. Also added the jQuery.param.fragment.noEscape method, and reworked the hashchange event (BBQ) internal "add" method to be compatible with changes made to the jQuery 1.4.2 special events API.
1.1.1 - (1/22/2010) Integrated jQuery hashchange event v1.1, which fixes an obscure IE8 EmulateIE7 meta tag compatibility mode bug.
View
2 docs/nd/Data/FileInfo.nd
@@ -1,4 +1,4 @@
1.4
JavaScript
/srv/projects/jquery-bbq-dev/jquery.ba-bbq.js 1282314036 1 jQuery BBQ: Back Button & Query Library
-/srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js 1282314039 0 /srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js
+/srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js 1282316475 0 /srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js
View
BIN docs/nd/Data/SymbolTable.nd
Binary file not shown.
View
47 unit/unit.js
@@ -72,6 +72,53 @@ var params_obj = { a:['4','5','6'], b:{x:['7'], y:'8', z:['9','0','true','false'
params_str = params_init,
params_str_old = 'a=4&a=5&a=6&b=[object+Object]&c=1';
+test( 'jQuery.param.sorted', function() {
+ var tests = [
+ {
+ obj: {z:1,b:2,ab:3,bc:4,ba:5,aa:6,a1:7,x:8},
+ traditional: false,
+ expected: 'a1=7&aa=6&ab=3&b=2&ba=5&bc=4&x=8&z=1'
+ },
+ {
+ obj: {z:1,b:[6,5,4],x:2,a:[3,2,1]},
+ traditional: false,
+ expected: 'a[]=3&a[]=2&a[]=1&b[]=6&b[]=5&b[]=4&x=2&z=1',
+ expected_old: 'a=3&a=2&a=1&b=6&b=5&b=4&x=2&z=1'
+ },
+ {
+ obj: {z:1,b:[6,5,4],x:2,a:[3,2,1]},
+ traditional: true,
+ expected: 'a=3&a=2&a=1&b=6&b=5&b=4&x=2&z=1'
+ },
+ {
+ obj: {a:[[4,[5,6]],[[7,8],9]]},
+ traditional: false,
+ expected: 'a[0][]=4&a[0][1][]=5&a[0][1][]=6&a[1][0][]=7&a[1][0][]=8&a[1][]=9',
+ expected_old: 'a=4,5,6&a=7,8,9' // obviously not great, but that's the way jQuery used to roll
+ }
+ ];
+
+ if ( $.fn.jquery != '1.4.1' ) {
+ // this explodes in jQuery 1.4.1
+ tests.push({
+ obj: {z:1,'b[]':[6,5,4],x:2,'a[]':[3,2,1]},
+ obj_alt: {z:1,b:[6,5,4],x:2,a:[3,2,1]},
+ traditional: false,
+ expected: 'a[]=3&a[]=2&a[]=1&b[]=6&b[]=5&b[]=4&x=2&z=1'
+ });
+ }
+
+ expect( tests.length * 2 );
+
+ $.each( tests, function(i,test){
+ var unsorted = $.param( test.obj, test.traditional ),
+ sorted = $.param.sorted( test.obj, test.traditional );
+
+ equals( decodeURIComponent( sorted ), old_jquery && test.expected_old || test.expected, 'params should be sorted' );
+ same( $.deparam( unsorted, true ), $.deparam( sorted, true ), 'sorted params should deparam the same as unsorted params' )
+ });
+});
+
test( 'jQuery.param.querystring', function() {
expect( 11 );

0 comments on commit aa12c92

Please sign in to comment.
Something went wrong with that request. Please try again.