Sha256: 6aea405b5d51bb184bff00b5e41a62ec99f72f3f49c8ffc38f99b7528411085f
Contents?: true
Size: 1.63 KB
Versions: 11
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
11 entries across 11 versions & 1 rubygems