Sha256: 8ebcde0591d412cb640d067b1360cba8d8647b0d76ed92b1ae3cb71e645350b0

Contents?: true

Size: 1.35 KB

Versions: 17

Compression:

Stored size: 1.35 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2010 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
/*globals module ok equals same test MyApp */

var MyFoo = null, callInfo ;
module("SC.Record#refresh", {
  setup: function() {
    SC.RunLoop.begin();
    MyApp = SC.Object.create({
      store: SC.Store.create()
    })  ;
  
    MyApp.Foo = SC.Record.extend();
    MyApp.json = { 
      foo: "bar", 
      number: 123,
      bool: YES,
      array: [1,2,3] 
    };
    
    MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
    
    // modify store so that everytime refreshRecords() is called it updates 
    // callInfo
    callInfo = null ;
    MyApp.store.refreshRecord = function(records) {
      callInfo = SC.A(arguments) ; // save method call
    };
  },
  
  teardown: function() {
    SC.RunLoop.end();
  }
  
});

test("calling refresh should call refreshRecord() on store", function() {
  MyApp.foo.refresh();
  same(callInfo, [null,null,MyApp.foo.storeKey], 'refreshRecord() should be called on parent');
});

test("should return receiver", function() {
  equals(MyApp.foo.refresh(), MyApp.foo, 'should return receiver');
});

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.5.0.pre.3 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.5 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.5-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.4-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.4 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.3.1 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.3-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.3 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.2-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.2 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.1-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.1 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.0-java lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js
sproutcore-1.4.0 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/refresh.js