From 3c05504a0b1bf15d0b0c1ce2eeb1196bdfc700c0 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Tue, 27 Aug 2013 09:30:30 -0400 Subject: [PATCH] sorting test --- test/index.html | 110 +++++++++++++---------------------------------- test/sorting1.js | 44 +++++++++++++++++++ 2 files changed, 74 insertions(+), 80 deletions(-) create mode 100644 test/sorting1.js diff --git a/test/index.html b/test/index.html index d8211a4..d35292a 100644 --- a/test/index.html +++ b/test/index.html @@ -6,98 +6,48 @@ Masonry tests - + - - - - - - - - - - - - - + - - - - - + + + + + + + + + + + + + + + + + + -

Masonry tests

+

Isotope tests

-

Basic layout top left

- -
-
-
-
-
-
-
+

Sorting

-

Basic layout top right

-
-
-
-
-
-
+
+
B4
+
B2
+
A4
+
A1
+
B1
+
A3
+
A2
-

Basic layout bottom left

-
-
-
-
-
-
-
- -

Basic layout bottom right

-
-
-
-
-
-
-
- -

Gutter

-
-
-
-
-
-
- -

Stamp

-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
diff --git a/test/sorting1.js b/test/sorting1.js new file mode 100644 index 0000000..7a0bec3 --- /dev/null +++ b/test/sorting1.js @@ -0,0 +1,44 @@ +( function() { + +'use strict'; + +var docElem = document.documentElement; + +var getText = docElem.textContent ? + function( elem ) { + return elem.textContent; + } : + function( elem ) { + return elem.innerText; + }; + +function getItemsText( iso ) { + var texts = []; + for ( var i=0, len = iso.filteredItems.length; i < len; i++ ) { + var item = iso.filteredItems[i]; + texts.push( getText( item.element ) ); + } + return texts.join(','); +} + +test( 'sort uses history', function() { + var iso = new Isotope( '#sorting1', { + layoutMode: 'fitRows', + transitionDuration: 0, + getSortData: { + letter: 'b', + number: 'i' + }, + sortBy: 'number' + }); + + iso.layout({ sortBy: 'letter' }); + + var texts = getItemsText( iso ); + + equal( texts, 'A1,A2,A3,A4,B1,B2,B4', 'items sorted by letter, then number, via history' ); + + iso.destroy(); +}); + +})();