<commit_before>// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            portions copyright @2009 Apple Inc.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test htmlbody ok equals same stop start */

// htmlbody('<style> .sc-control-test-pane .wrapper { overflow: none; } </style>');

(function() {
  var pane = SC.ControlTestPane.design({ height: 100 });
  
  pane.add("basic", SC.ContainerView, {
      isEnabled: YES
    });
    
  pane.add("disabled", SC.ContainerView, {
      isEnabled: NO
    });
    
    // .add("disabled - single selection", SC.ListView, {
    //   isEnabled: NO,
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: singleSelection
    // })
    // 
    // .add("single selection", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: singleSelection
    // })
    // 
    // .add("multiple selection, contiguous", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: multiSelectionContiguous
    // })
    // 
    // .add("multiple selection, discontiguous", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: multiSelectionDiscontiguous
    // })
    
  pane.show(); // add a test to show the test pane

  // ..........................................................
  // TEST VIEWS
  // 
  module('SC.ContainerView UI', pane.standardSetup());
  
  test("basic", function() {
    var view = pane.view('basic');
    ok(!view.$().hasClass('disabled'), 'should not have disabled class');
    ok(!view.$().hasClass('sel'), 'should not have sel class');
    
    // var contentView = view.get('contentView') ;
    // ok(contentView.kindOf(SC.ContainerView), 'default contentView is an SC.ContainerView');
    // ok(contentView.get('contentView') === null, 'default contentView should have no contentView itself');
  });
  
  test("disabled", function() {
    var view = pane.view('disabled');
    ok(view.$().hasClass('disabled'), 'should have disabled class');
    ok(!view.$().hasClass('sel'), 'should not have sel class');
  });
   
  // test("disabled - single selection", function() {
  //   var view = pane.view('disabled - single selection');
  //   ok(view.$().hasClass('disabled'), 'should have disabled class');
  //   ok(view.itemViewAtContentIndex(0).$().hasClass('sel'), 'should have sel class');
  //  });
  // 
  //  test("single selection", function() {
  //    var view = pane.view('single selection');
  //    ok(view.itemViewAtContentIndex(0).$().hasClass('sc-collection-item'), 'should have sc-collection-item class');
  //    ok(view.itemViewAtContentIndex(0).$().hasClass('sel'), 'should have sel class');
  //   });

})();<commit_msg>Added unit test (I think) that tests the ContainerView's nowShowing feature (I think).<commit_after>// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Sprout Systems, Inc. and contributors.
//            portions copyright @2009 Apple Inc.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test htmlbody ok equals same stop start */

// htmlbody('<style> .sc-control-test-pane .wrapper { overflow: none; } </style>');

(function() {
  var pane = SC.ControlTestPane.design({ height: 100 });
  
  pane.add("basic", SC.ContainerView, {
      isEnabled: YES
    });
    
  pane.add("disabled", SC.ContainerView, {
      isEnabled: NO
    });
    
    // .add("disabled - single selection", SC.ListView, {
    //   isEnabled: NO,
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: singleSelection
    // })
    // 
    // .add("single selection", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: singleSelection
    // })
    // 
    // .add("multiple selection, contiguous", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: multiSelectionContiguous
    // })
    // 
    // .add("multiple selection, discontiguous", SC.ListView, {
    //   content: content,
    //   contentValueKey: 'title',
    //   selection: multiSelectionDiscontiguous
    // })
    
  pane.show(); // add a test to show the test pane

  // ..........................................................
  // TEST VIEWS
  // 
  module('SC.ContainerView UI', pane.standardSetup());
  
  test("basic", function() {
    var view = pane.view('basic');
    ok(!view.$().hasClass('disabled'), 'should not have disabled class');
    ok(!view.$().hasClass('sel'), 'should not have sel class');
    
    var contentView = view.get('contentView') ;
    
    // ok(contentView.kindOf(SC.ContainerView), 'default contentView is an SC.ContainerView');
    // ok(contentView.get('contentView') === null, 'default contentView should have no contentView itself');
  });
  
  test("disabled", function() {
    var view = pane.view('disabled');
    ok(view.$().hasClass('disabled'), 'should have disabled class');
    ok(!view.$().hasClass('sel'), 'should not have sel class');
  });
   
  // test("disabled - single selection", function() {
  //   var view = pane.view('disabled - single selection');
  //   ok(view.$().hasClass('disabled'), 'should have disabled class');
  //   ok(view.itemViewAtContentIndex(0).$().hasClass('sel'), 'should have sel class');
  //  });
  // 
  //  test("single selection", function() {
  //    var view = pane.view('single selection');
  //    ok(view.itemViewAtContentIndex(0).$().hasClass('sc-collection-item'), 'should have sc-collection-item class');
  //    ok(view.itemViewAtContentIndex(0).$().hasClass('sel'), 'should have sel class');
  //   });

  test("changing nowShowing", function() {
    var view = pane.view('basic');
    // Set nowShowing to an instantiated object.
    var viewToAdd = SC.LabelView.create({value = 'Test view.'});
    view.set('nowShowing', viewToAdd);
    ok(view.get('contentView') instanceof SC.View, 'contentView changes as intended when an instantiated view is passed to nowShowing');
    
    // Set nowShowing to an uninstantiated object.
    var viewToAdd = SC.LabelView.design({value = 'Test view.'});
    view.set('nowShowing', viewToAdd);
    ok(view.get('contentView') instanceof SC.View, 'contentView changes as intended when an uninstantiated view (class) is passed to nowShowing');
    
    // Set nowShowing to a non-view object.
    var viewToAdd = SC.Record;
    view.set('nowShowing', viewToAdd);
    ok(SC.typeOf(view.get('contentView')) === SC.T_NULL, 'contentView changes to null when nowShowing is set to a non-view');
    
    // Set nowShowing to a string.  (How, here?) (No idea.)
    
    // Set nowShowing to a nonexistent string.
    var viewToAdd = 'NonexistentNamespace.NonexistentViewClass';
    view.set('nowShowing', viewToAdd);
    ok(SC.typeOf(view.get('contentView')) === SC.T_NULL, 'contentView changes to null when nowShowing is set to a string pointing at nothing');
    
    // Set nowShowing to null.
    var viewToAdd = null;
    view.set('nowShowing', viewToAdd);
    ok(SC.typeOf(view.get('contentView')) === SC.T_NULL, 'contentView changes to null when nowShowing is set to null');
    
  });

})();
{'fraction_non_alphanumeric': 0.2126625508997767, 'fraction_numerical': 0.004728753448049389, 'mean_word_length': 2.8748091603053436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4620205', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2156, 'n_words': 548}