Skip to content

Commit

Permalink
added more $.param.sorted unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Aug 20, 2010
1 parent 6c6bade commit aa12c92
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
7 changes: 4 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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/)
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/nd/Data/FileInfo.nd
Original file line number Diff line number Diff line change
@@ -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
Binary file modified docs/nd/Data/SymbolTable.nd
Binary file not shown.
47 changes: 47 additions & 0 deletions unit/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit aa12c92

Please sign in to comment.