Ticket #5357: dojo.data.ItemFileWriteStore_20071213.patch

File dojo.data.ItemFileWriteStore_20071213.patch, 2.0 kB (added by jaredj, 13 months ago)

Patch for this + UT.

  • tests/data/ItemFileWriteStore.js

     
    621621                        store.save({onComplete:onComplete, onError:onError}); 
    622622                        return deferred; //Object 
    623623                }, 
     624                function testWriteAPI_newItem_revert(){ 
     625                        //      summary:  
     626                        //              Test for bug #5357.  Ensure that the revert properly nulls the identity position 
     627                        //      for a new item after revert. 
     628                        var args = {data: { 
     629                                label:"name", 
     630                                items:[ 
     631                                        {name:'Ecuador', capital:'Quito'}, 
     632                                        {name:'Egypt', capital:'Cairo'}, 
     633                                        {name:'El Salvador', capital:'San Salvador'}, 
     634                                        {name:'Equatorial Guinea', capital:'Malabo'}, 
     635                                        {name:'Eritrea', capital:'Asmara'}, 
     636                                        {name:'Estonia', capital:'Tallinn'}, 
     637                                        {name:'Ethiopia', capital:'Addis Ababa'} 
     638                                ] 
     639                        } };  
     640                        var store = new dojo.data.ItemFileWriteStore(args); 
     641 
     642                        var newCountry = store.newItem({name: "Utopia", capitol: "Perfect"}); 
     643 
     644                        //DO NOT ACCESS THIS WAY.  THESE ARE INTERNAL VARIABLES.  DOING THIS FOR TEST PURPOSES. 
     645                        var itemEntryNum = newCountry[store._itemNumPropName]; 
     646                        doh.assertTrue(store._arrayOfAllItems[itemEntryNum] === newCountry); 
     647                        store.revert(); 
     648                        doh.assertTrue(store._arrayOfAllItems[itemEntryNum] === null); 
     649                }, 
    624650                function testNotificationAPI_onSet(){ 
    625651                        //      summary:  
    626652                        //              Simple test of the onSet API 
  • data/ItemFileWriteStore.js

     
    435435                        newItem[this._storeRefPropName] = null; 
    436436                        // null out the new item, but don't change the array index so 
    437437                        // so we can keep using _arrayOfAllItems.length. 
    438                         this._arrayOfAllItems[newItem._itemNumPropName] = null; 
     438                        this._arrayOfAllItems[newItem[this._itemNumPropName]] = null; 
    439439                        if(newItem[this._rootItemPropName]){ 
    440440                                this._removeArrayElement(this._arrayOfTopLevelItems, newItem); 
    441441                        }