Sha256: 6271e5cb54b07ad15662efc49502dc4143846471ae4f20b454ac9e8c7c1ec29a

Contents?: true

Size: 1.71 KB

Versions: 16

Compression:

Stored size: 1.71 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 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

16 entries across 16 versions & 1 rubygems

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