Browse Source

layoutComplete tests

pull/563/head
David DeSandro 12 years ago
parent
commit
b19c848467
  1. 9
      notes.md
  2. 4
      test/get-sort-data.js
  3. 15
      test/index.html
  4. 73
      test/layout-complete.js

9
notes.md

@ -12,13 +12,4 @@ filter
updateSortData updateSortData
layoutComplete test after
filter - hide some
filter - reveal some, some stay hidden, some are revealed, some do nothing
sort
filter, during transition filter again
## bugs ## bugs

4
test/get-sort-data.js

@ -8,7 +8,8 @@ test( 'getSortData', function() {
ninjaTurtle: '[data-ninja-turtle]', ninjaTurtle: '[data-ninja-turtle]',
fruit: 'span.fruit', fruit: 'span.fruit',
b: 'b parseFloat', b: 'b parseFloat',
i: 'i parseInt' i: 'i parseInt',
bbroke: 'b foobar'
} }
}); });
@ -18,5 +19,6 @@ test( 'getSortData', function() {
equal( item.sortData.fruit, 'watermelon', 'query selector shorthand' ); equal( item.sortData.fruit, 'watermelon', 'query selector shorthand' );
equal( item.sortData.b, 3.14, 'parseFloat parser' ); equal( item.sortData.b, 3.14, 'parseFloat parser' );
equal( item.sortData.i, 42, 'parseInt parser' ); equal( item.sortData.i, 42, 'parseInt parser' );
equal( item.sortData.bbroke, '3.14', 'default nonparser' );
}); });

15
test/index.html

@ -29,6 +29,7 @@
<script src="sorting.js"></script> <script src="sorting.js"></script>
<script src="get-sort-data.js"></script> <script src="get-sort-data.js"></script>
<script src="layout-complete.js"></script>
</head> </head>
<body> <body>
@ -59,5 +60,19 @@
</div> </div>
</div> </div>
<h2>layoutComplete</h2>
<div id="layout-complete" class="container">
<div class="item a1 b1">a1 b1</div>
<div class="item a2 b1">a2 b1</div>
<div class="item a3 b1">a3 b1</div>
<div class="item a1 b2">a1 b2</div>
<div class="item a2 b2">a2 b2</div>
<div class="item a3 b2">a3 b2</div>
<div class="item a1 b3">a1 b3</div>
<div class="item a2 b3">a2 b3</div>
<div class="item a3 b3">a3 b3</div>
</div>
</body> </body>
</html> </html>

73
test/layout-complete.js

@ -0,0 +1,73 @@
test( 'layoutComplete', function() {
'use strict';
var iso = new Isotope( '#layout-complete', {
layoutMode: 'fitRows',
transitionDuration: '0.1s'
});
var tests = [
function() {
iso.once( 'layoutComplete', function() {
ok( true, 'layoutComplete after some were filtered' );
next();
});
iso.layout({
filter: '.a1'
});
},
function() {
iso.once( 'layoutComplete', function() {
ok( true, 'after some revealed, some hidden, some same' );
next();
});
iso.layout({
filter: '.b2'
});
},
function() {
iso.once( 'layoutComplete', function() {
ok( true, 'after random sort' );
next();
});
iso.layout({
sortBy: 'random'
});
},
function() {
iso.once( 'layoutComplete', function() {
ok( true, 'after layout mid-way thru transition' );
next();
});
iso.layout({
filter: '.a2',
transitionDuration: '0.6s'
});
setTimeout( function() {
iso.layout({
filter: '.b2'
});
}, 300 );
}
];
function next() {
if ( tests.length ) {
var nextTest = tests.shift();
// HACK for consecutive layoutComplete calls
setTimeout( nextTest );
} else {
start();
}
}
next();
stop();
});
Loading…
Cancel
Save