Sha256: 737b96b5369969230933f657a02cb0089e56d047b1368fa81db940d5292c4e62

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

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

var MyApp, dataSource;
module("SC.Record core methods", {
  setup: function() {
    dataSource = SC.DataSource.create({ 
      
      gotParams: NO,
      wasCommitted: NO,
      
      createRecord: function(store, storeKey, params) {
        this.wasCommitted = YES;
        this.gotParams = params && params['param1'] ? YES: NO;
      }});
    
    MyApp = SC.Object.create({
      store: SC.Store.create().from(dataSource)
    })  ;
  
    MyApp.Foo = SC.Record.extend({});
    MyApp.json = { 
      foo: "bar", 
      number: 123,
      bool: YES,
      array: [1,2,3],
      guid: 1
    };
    
    SC.RunLoop.begin();
    MyApp.foo = MyApp.store.createRecord(MyApp.Foo, MyApp.json);
    SC.RunLoop.end();
    
  }
});

test("statusString", function() {
  equals(MyApp.foo.statusString(), 'READY_NEW', 'status string should be READY_NEW');
});

test("Can commitRecord() specific SC.Record instance", function() {
  
  MyApp.foo.set('foo', 'foobar');
  
  // commit the new record
  MyApp.foo.commitRecord({ param1: 'value1' });
  
  equals(dataSource.wasCommitted, YES, 'Record was committed');
  equals(dataSource.gotParams, YES, 'Params were properly passed through commitRecord');
  
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sproutcore-1.4.0.rc.5 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.4.0.rc.4 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.4.0.rc.3 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.4.0.rc.2 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.4.0.rc lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.0.1049.pre.2 lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js
sproutcore-1.0.1049.pre.1 frameworks/sproutcore/frameworks/datastore/tests/models/record/core_methods.js