Sha256: e86dc4cbe784678987892d1af0841741369b69bdb2cbcc46306a5c8194be4f2f

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2009 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

7 entries across 7 versions & 1 rubygems

Version Path
sproutcore-1.4.0.rc.5 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.4.0.rc.4 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.4.0.rc.3 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.4.0.rc.2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.4.0.rc lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.0.1049.pre.2 lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js
sproutcore-1.0.1049.pre.1 frameworks/sproutcore/frameworks/datastore/tests/system/query/queryWithScope.js