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("shiftObject"), { 17 setup: function() { 18 obj = T.newObject(); 19 observer = T.observer(obj); 20 } 21 }); 22 23 test("[].shiftObject() => [] + returns undefined + NO notify", function() { 24 observer.observe('[]', 'length') ; 25 equals(obj.shiftObject(), undefined, 'should return undefined') ; 26 T.validateAfter(obj, [], observer, NO, NO); 27 }); 28 29 test("[X].shiftObject() => [] + notify", function() { 30 var exp = T.expected(1)[0]; 31 32 obj.replace(0,0, [exp]); 33 observer.observe('[]', 'length') ; 34 35 equals(obj.shiftObject(), exp, 'should return shifted object') ; 36 T.validateAfter(obj, [], observer, YES, YES); 37 }); 38 39 test("[A,B,C].shiftObject() => [B,C] + notify", function() { 40 var before = T.expected(3), 41 value = before[0], 42 after = before.slice(1); 43 44 obj.replace(0,0,before); 45 observer.observe('[]', 'length') ; 46 equals(obj.shiftObject(), value, 'should return shifted object') ; 47 T.validateAfter(obj, after, observer, YES); 48 }); 49 50 }); 51