1 // ========================================================================== 2 // Project: SproutCore Costello - Property Observing Library 3 // Copyright: ©2006-2011 Strobe Inc. and contributors. 4 // Portions ©2008-2011 Apple Inc. All rights reserved. 5 // License: Licensed under MIT license (see license.js) 6 // ========================================================================== 7 8 /*globals module test ok equals same CoreTest */ 9 10 sc_require('debug/test_suites/array/base'); 11 12 SC.ArraySuite.define(function(T) { 13 14 var observer, obj ; 15 16 module(T.desc("pushObject"), { 17 setup: function() { 18 obj = T.newObject(); 19 observer = T.observer(obj); 20 } 21 }); 22 23 test("returns pushed object", function() { 24 var exp = T.expected(1)[0]; 25 equals(obj.pushObject(exp), exp, 'should return receiver'); 26 }); 27 28 test("[].pushObject(X) => [X] + notify", function() { 29 var exp = T.expected(1); 30 observer.observe('[]', 'length') ; 31 obj.pushObject(exp[0]) ; 32 T.validateAfter(obj, exp, observer, YES); 33 }); 34 35 test("[A,B,C].pushObject(X) => [A,B,C,X] + notify", function() { 36 var after = T.expected(4), 37 before = after.slice(0,3), 38 value = after[3]; 39 40 obj.replace(0,0,before); 41 observer.observe('[]', 'length') ; 42 obj.pushObject(value) ; 43 T.validateAfter(obj, after, observer, YES); 44 }); 45 46 }); 47