Sha256: 6f70549b38b5ff4654971965bd1474b7e8959fe4a503a248569287bcf6372337

Contents?: true

Size: 1.71 KB

Versions: 41

Compression:

Stored size: 1.71 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
/*globals module ok equals same test MyApp */
 
// test parsing of query string
var q, scope1, scope2;
module("SC.Query#queryWithScope", {
  setup: function() {
    q = SC.Query.create({
      conditions: "foo = bar",
      parameters: { foo: "bar" },
      orderBy: "foo",
      recordType: SC.Record,
      recordTypes: [SC.Record],
      location: SC.Query.REMOTE
    }).freeze();
    
    scope1 = SC.CoreSet.create();
    scope2 = SC.CoreSet.create();
  },
  
  teardown: function() {
    q = scope1 = scope2 = null;
  }
});

function verifyCopy(copy, original) {
  var keys = 'conditions orderBy recordType recordTypes parameters location'.w();
  keys.forEach(function(key) {
    equals(copy.get(key), original.get(key), 'copy.%@ should equal original.%@'.fmt(key, key));
  });
}

test("getting into scope first time", function() {
  
  var q2 = q.queryWithScope(scope1);
  verifyCopy(q2, q);
  equals(q2.get('scope'), scope1, 'new query should have scope1');
  
  var q3 = q.queryWithScope(scope1);
  equals(q3, q2, 'calling again with same scope should return same instance');
});

test("chained scope", function() {
  var q2 = q.queryWithScope(scope1) ;
  var q3 = q2.queryWithScope(scope2);
  
  verifyCopy(q3, q2);
  equals(q3.get('scope'), scope2, 'new query should have scope2');
  
  var q4 = q2.queryWithScope(scope2);
  equals(q4, q3, 'calling again with same scope should return same instance');
});

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js