Sha256: 46ae05ae246bf8e2c611464a3777675438d7d43b2a2e42f3fce0d8b9086ce609
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 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 */ (function() { var store, Person, Male, Female, colin, maggie; module("Polymorphic SC.Record - Simple", { setup: function() { SC.RunLoop.begin(); store = SC.Store.create(); Person = SC.Record.extend(); Person.isPolymorphic = YES; Male = Person.extend({ isMale: YES }); Female = Person.extend({ isFemale: YES }); colin = store.createRecord(Male, { guid: '1' }); maggie = store.createRecord(Female, { guid: '2' }); }, teardown: function() { store = Person = Male = Female = colin = maggie = null; SC.RunLoop.end(); } }); test("SC.Store#find works with abstract record type", function() { var person1 = store.find(Person, '1'), person2 = store.find(Person, '2'); equals(person1, colin, "find on Person record type with guid 1 should return male record"); ok(SC.kindOf(person1, Male) && person1.isMale, "returned record should be of type Male"); equals(person2, maggie, "find on Person record type with guid 2 should return female record"); ok(SC.kindOf(person2, Female) && person2.isFemale, "returned record should be of type Female"); }); test("Creating a record of a different concrete type with the same id errors", function() { expect(1); try { store.createRecord(Female, { guid: '1' }); } catch (e) { ok(true, "Error occured when trying to create type with same guid"); } }); })();
Version data entries
2 entries across 2 versions & 1 rubygems