Sha256: c9cb64706dd1c4619189161c5870dc4bcba3df9654d4698c5b86fb339d1b1fcf

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 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 */

// test parsing of query string
var rec, q;
module("SC.Query comparison of record types", {
  setup: function() {
    // setup dummy app and store
    window.MyApp = SC.Object.create({
      store: SC.Store.create()
    });
    
    // setup a dummy model
    window.MyApp.Foo = SC.Record.extend({});
    
    // load some data
    window.MyApp.store.loadRecords(window.MyApp.Foo, [
      { guid: 1, firstName: "John", lastName: "Doe" }
    ]);
    
    rec = window.MyApp.store.find(window.MyApp.Foo,1);
    
    q = SC.Query.create();
  }
});


  
test("should handle record types", function() {
  
  q.conditions = "TYPE_IS 'MyApp.Foo'";
  q.parse();
  equals(SC.Store.recordTypeFor(rec.storeKey), SC.objectForPropertyPath('MyApp.Foo'), 'record type should be MyApp.Foo');
  ok(q.contains(rec), 'record with proper type should match');
  
  q.conditions = "TYPE_IS 'MyApp.Baz'";
  q.parse();
  ok(!q.contains(rec), 'record with wrong type should not match');
});

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sproutcore-1.0.1046 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1043 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1042 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1037 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1035 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1031 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1030 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1029 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1027 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1028 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1026 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1025 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1024 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1009 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1008 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js
sproutcore-1.0.1003 frameworks/sproutcore/frameworks/datastore/tests/system/query/record_type_is.js