Sha256: 66c44f3fe423a113099c6413af2345608f7a6fca65f4ce9f853957f58f8d467b

Contents?: true

Size: 1.54 KB

Versions: 18

Compression:

Stored size: 1.54 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 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

18 entries across 18 versions & 2 rubygems

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