Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.97 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. suite.add(new Y.Test.Case({
  2.         name: 'batch',
  3.        
  4.         setUp: function(){
  5.             spy.watchClass({
  6.                 name: 'Ext.data.Batch',
  7.                 functions: ['add', 'start']
  8.             });
  9.             spy.watchClass({
  10.                name: 'Ext.data.Operation'
  11.             });
  12.         },
  13.         tearDown: function(){
  14.             spy.unWatchClass('Ext.data.Batch');
  15.             spy.unWatchClass('Ext.data.Operation');
  16.         },
  17.         testBatch: function() {
  18.             var batchOperations = {
  19.                 create : [AlienModel, HumanModel],
  20.                 update : [AlienModel]
  21.             };
  22.             var batchListeners = {
  23.                 complete: {
  24.                     fn    : Ext.emptyFn,
  25.                     scope : this
  26.                 }
  27.             };
  28.             var proxy = new Proxy();
  29.  
  30.            
  31.             var batch = proxy.batch(batchOperations, batchListeners);
  32.            
  33.             // batch instanciation and functions calls
  34.             spy.verifyClass('Ext.data.Batch',{
  35.                 args: [[{proxy: proxy, listeners: batchListeners}]],
  36.                 functions: [{
  37.                     name: 'add',
  38.                     calls: 3,
  39.                     scopes: [batch, batch, batch]
  40.                 },{
  41.                     name: 'start',
  42.                     args: [[undefined]],
  43.                     scopes: [batch]
  44.                }]
  45.             });
  46.            
  47.             spy.verifyClass('Ext.data.Operation',{
  48.                 args: [[{
  49.                         action : 'create',
  50.                         records: batchOperations.create
  51.                        }],
  52.                        [{
  53.                         action : 'update',
  54.                         records: batchOperations.update
  55.                        }],
  56.                        [{
  57.                         action : 'destroy',
  58.                         records: undefined
  59.                        }]]
  60.             });
  61.         }
  62.     }));