Guest User

Untitled

a guest
Feb 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. <% # ========================================================================
  2. # SC.ListView Unit Test
  3. # ========================================================================
  4. %>
  5. <% content_for('final') do %>
  6.  
  7. <script>
  8. // create some item data...
  9. [
  10. { guid: '1001', name: 'item one' },
  11. { guid: '1002', name: 'item two' },
  12. { guid: '1003', name: 'item three' },
  13. { guid: '1004', name: 'item four' },
  14. { guid: '1005', name: 'item five' },
  15. { guid: '1006', name: 'item six' }
  16. ].each(function(o){ SC.Store.addRecord(SC.Record.create(o)); });
  17.  
  18. // a collection to hold the items...
  19. testCollection = SC.Record.collection();
  20. testCollection.refresh();
  21.  
  22. // a controller for the collection...
  23. testController = SC.CollectionController.create();
  24.  
  25.  
  26.  
  27. Test.context("SC.ListView",{
  28.  
  29. "SC.ListView should add childNodes even when it is not visible": function() {
  30. testListView.get('childNodes').length.shouldEqual(6) ;
  31. },
  32.  
  33. setup: function()
  34. {
  35.  
  36. paneView = SC.PaneView.create();
  37. paneView.set('isVisible',false);
  38. paneView.set('height',500);
  39. paneView.set('width',500);
  40. SC.window.appendChild(paneView);
  41. // add a scroll view wrapper.
  42. scrollView = SC.ScrollView.create() ;
  43. scrollView.set('frame', { x: 10, y: 10, width: 400, height: 400 }) ;
  44. paneView.appendChild(scrollView) ;
  45.  
  46. // create the view...
  47. testListView = SC.ListView.create({
  48. contentValueKey: 'name',
  49. contentBinding: 'testController.arrangedObjects',
  50. selectionBinding: 'testController.selection',
  51. height: 300,
  52. width: 300
  53. }) ;
  54. scrollView.set('content', testListView) ;
  55.  
  56. testController.set('content', testCollection) ;
  57. },
  58.  
  59. teardown: function()
  60. {
  61. // remove the view from SC.window
  62. testListView.removeFromParent() ;
  63. scrollView.removeFromParent() ;
  64. paneView.removeFromParent();
  65.  
  66. delete testListView ;
  67. delete scrollView ;
  68. delete paneView;
  69.  
  70. testController.set('content', null) ;
  71. }
  72.  
  73.  
  74. }) ;
  75.  
  76.  
  77. </script>
  78.  
  79. <% end %>
Add Comment
Please, Sign In to add comment