// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2011 Apple Inc. and contributors. // License: Licensed under MIT license (see license.js) // ========================================================================== /*global module test equals context ok same */ // .......................................................... // createChildViews() // module("SC.View#createChildViews"); test("calls createChildView() for each class or string in childViews array", function() { var called = []; var v = SC.View.create({ childViews: [ SC.View.extend({ key: 0 }), // class - should be called SC.View.create({ key: 1 }), // instance - will be called 'customClassName' // string - should be called ], // this should be used for the 'customClassName' item above customClassName: SC.View.extend({ key: 2 }), // patch to record results... createChildView: function(childView) { if(childView.isClass) { called.push(childView.prototype.key); } else { called.push(childView.key); } return sc_super(); } }); // createChildViews() is called automatically during create. same(called, [0,1,2], 'called createChildView for correct children'); // make sure childViews array is correct now. var cv = v.childViews, len = cv.length, idx; for(idx=0;idx