Sha256: 2ad0f31e6906b093c04810c49fc58b9f59dd30d2556aa8625694eb6b26c2f9ae

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

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

var store, storeKey, json, hash, hash2;

module("SC.Store#createRecord", {
  setup: function() {
    
    store = SC.Store.create();
    
    json = {
      string: "string",
      number: 23,
      bool:   YES
    };
    
    storeKey = SC.Store.generateStoreKey();

    store.writeDataHash(storeKey, json, SC.Record.READY_CLEAN);
  }
});

test("create a record", function() {
  var sk;
  var rec = SC.Record.create();
  hash = {
    guid: "1234abcd",
    string: "abcd",
    number: 1,
    bool:   NO
    };
  hash2 = {
    string: "abcd",
    number: 1,
    bool:   NO
  };

  rec = store.createRecord(SC.Record, hash);
  ok(rec, "a record was created");
  sk=store.storeKeyFor(SC.Record, rec.id());
  equals(store.readDataHash(sk), hash, "data hashes are equivalent");
  equals(rec.id(), "1234abcd", "guids are the same");

  rec = store.createRecord(SC.Record, hash2, "priKey");
  ok(rec, "a record with a custom id was created");
  sk=store.storeKeyFor(SC.Record, "priKey");
  equals(store.readDataHash(sk), hash2, "data hashes are equivalent");
  equals(rec.id(), "priKey", "guids are the same");
  
  equals(store.changelog.length, 2, "The changelog has the following number of entries:");
  
  
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sproutit-sproutcore-1.0.0.20090408130025 frameworks/sproutcore/frameworks/datastore/tests/system/store/createRecord.js
sproutit-sproutcore-1.0.0.20090416161445 frameworks/sproutcore/frameworks/datastore/tests/system/store/createRecord.js