Sha256: 86fef27fd02f3c782b7163ece6d13db5a06e132adc4115ccf9c36eb39b3a9fbc

Contents?: true

Size: 1006 Bytes

Versions: 17

Compression:

Stored size: 1006 Bytes

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 Apple Inc. and contributors.
// License:   Licened under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same */

var parent, child;
module("SC.View#replaceChild", {
	setup: function() {
	  child = SC.View.create();
	  parent = SC.View.create({
	    childViews: [SC.View, SC.View, SC.View]
	  });		
	}
});


test("swaps the old child with the new child", function() {
  var oldChild = parent.childViews[1];

  parent.replaceChild(child, oldChild);
  equals(child.get('parentView'), parent, 'child has new parent');
  ok(!oldChild.get('parentView'), 'old child no longer has parent');
  
  equals(parent.childViews[1], child, 'parent view has new child at loc 1');
  equals(parent.childViews.length, 3, 'parent has same number of children');
});

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
sproutit-sproutcore-1.0.20090721145285 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1046 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1043 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1042 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1037 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1035 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1031 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1030 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1029 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1027 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1028 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1026 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1025 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1024 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1009 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1008 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js
sproutcore-1.0.1003 frameworks/sproutcore/frameworks/foundation/tests/views/view/replaceChild.js