Sha256: 903826a57c43c4c213877adc955398378bff576aea8e7fd303ece6c96704f310
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 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, Foo, json, foo ; module("SC.Record#readAttribute", { setup: function() { store = SC.Store.create(); Foo = SC.Record.extend(); json = { foo: "bar", number: 123, bool: YES, array: [1,2,3] }; foo = store.createRecord(Foo, json); store.writeStatus(foo.storeKey, SC.Record.READY_CLEAN); } }); test("returns unaltered JSON value for existing attributes", function() { var key ; for(key in json) { if (!json.hasOwnProperty(key)) continue; equals(foo.get(key), json[key], 'should return value for predefined key %@'.fmt(key)); } }); test("returns undefined for unknown JSON attributes", function() { equals(foo.get('imaginary'), undefined, 'should return undefined for unknown key "imaginary"'); }); test("returns new value if edited via writeAttribute", function() { foo.writeAttribute("bar", "baz"); equals(foo.readAttribute("bar"), "baz", "should return value for new attribute 'bar'"); }); test("returns undefined when data hash is not present", function() { store.removeDataHash(foo.storeKey); equals(store.readDataHash(foo.storeKey), null, 'precond - data hash should be removed from store'); equals(foo.readAttribute("foo"), undefined, "should return undefined if data hash is missing"); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sproutit-sproutcore-1.0.20090721145285 | frameworks/sproutcore/frameworks/datastore/tests/models/record/readAttribute.js |