Sha256: 22233ee49834dc84286ed0acfd9882db633e127ab864bde0af333c6ad4eccc16
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
// ======================================================================== // SC.CollectionView selectPreviousItem Unit Test // ======================================================================== /*globals module test ok isObj equals expects */ var array, collectionView ; // global variables module("CollectionView selectPreviousItem", { setup: function() { array = [{ item:1 }, { item:2 }, { item:3 }, { item:4 }, { item:5 }] ; collectionView = SC.CollectionView.create({ content: array }) ; } }) ; test("should select previous item stepby numberOfItems", function() { // test stepby numberOfItems for selectPreviousItem [1,2,3].map(function(n) { for (var idx = array.length - 1; idx >= 0; idx--) { // set current selection to array idx collectionView.set('selection', [collectionView.get('content').get(idx)]) ; var c = collectionView.get('selection')[0].item; // perform selectPreviousItem with numberOfItems collectionView.selectPreviousItem(false, n) ; if (idx >= n) { // idx is >= stepby numberOfItems, a selectPreviousItem will be equal to current idx minus stepby numberOfItems equals(collectionView.selection[0].item, array[idx-n].item, 'selection(%@ of 5) should step back by n(%@) items'.fmt(c,n)) ; } else { // idx is < stepby numberOfItems, a selectPreviousItem will be equal to current idx equals(collectionView.selection[0].item, array[idx].item, 'selection(%@ of 5) should try to step back by n(%@) items'.fmt(c,n)) ; } } ; }) ; }) ;
Version data entries
2 entries across 2 versions & 1 rubygems