Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes broken compound queries test

  • Loading branch information...
commit f9941439a3f308602aef5746147acb8276c8762e 1 parent 3a2f807
@cezary cezary authored
Showing with 4 additions and 50 deletions.
  1. +4 −2 test/backbone-query-test.coffee
  2. +0 −48 test/backbone-query-test.js
View
6 test/backbone-query-test.coffee
@@ -216,8 +216,10 @@ test "Compound Queries", ->
$and:
likes: $lt: 15
$or:
- content: $like: "Dummy"
- featured:$exists:true
+ content:
+ $like: "Dummy"
+ featured:
+ $exists:true
$not:
colors: $contains: "yellow"
equal result.length, 1
View
48 test/backbone-query-test.js
@@ -1,14 +1,11 @@
(function() {
var QueryCollection, create, equals;
-
if (typeof require !== "undefined") {
QueryCollection = require("../js/backbone-query.js").QueryCollection;
} else {
QueryCollection = Backbone.QueryCollection;
}
-
equals = [];
-
if (typeof test === "undefined" || test === null) {
test = function(name, test_cb) {
return exports[name] = function(testObj) {
@@ -23,13 +20,11 @@
};
};
}
-
if (typeof equal === "undefined" || equal === null) {
equal = function(real, expected) {
return equals.push([real, expected]);
};
}
-
create = function() {
return new QueryCollection([
{
@@ -52,7 +47,6 @@
}
]);
};
-
test("Simple equals query", function() {
var a, result;
a = create();
@@ -62,7 +56,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});
-
test("Simple equals query (no results)", function() {
var a, result;
a = create();
@@ -71,7 +64,6 @@
});
return equal(result.length, 0);
});
-
test("Simple equals query with explicit $equal", function() {
var a, result;
a = create();
@@ -83,7 +75,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("$contains operator", function() {
var a, result;
a = create();
@@ -94,7 +85,6 @@
});
return equal(result.length, 2);
});
-
test("$ne operator", function() {
var a, result;
a = create();
@@ -105,7 +95,6 @@
});
return equal(result.length, 2);
});
-
test("$lt operator", function() {
var a, result;
a = create();
@@ -117,7 +106,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("$lte operator", function() {
var a, result;
a = create();
@@ -128,7 +116,6 @@
});
return equal(result.length, 2);
});
-
test("$gt operator", function() {
var a, result;
a = create();
@@ -140,7 +127,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});
-
test("$gte operator", function() {
var a, result;
a = create();
@@ -151,7 +137,6 @@
});
return equal(result.length, 2);
});
-
test("$between operator", function() {
var a, result;
a = create();
@@ -163,7 +148,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("$in operator", function() {
var a, result;
a = create();
@@ -174,7 +158,6 @@
});
return equal(result.length, 2);
});
-
test("$in operator with wrong query value", function() {
var a, result;
a = create();
@@ -185,7 +168,6 @@
});
return equal(result.length, 0);
});
-
test("$nin operator", function() {
var a, result;
a = create();
@@ -197,7 +179,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});
-
test("$all operator", function() {
var a, result;
a = create();
@@ -208,7 +189,6 @@
});
return equal(result.length, 2);
});
-
test("$all operator (wrong values)", function() {
var a, result;
a = create();
@@ -225,7 +205,6 @@
});
return equal(result.length, 0);
});
-
test("$any operator", function() {
var a, result;
a = create();
@@ -242,7 +221,6 @@
});
return equal(result.length, 2);
});
-
test("$size operator", function() {
var a, result;
a = create();
@@ -254,7 +232,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});
-
test("$exists operator", function() {
var a, result;
a = create();
@@ -265,7 +242,6 @@
});
return equal(result.length, 2);
});
-
test("$has operator", function() {
var a, result;
a = create();
@@ -277,7 +253,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});
-
test("$like operator", function() {
var a, result;
a = create();
@@ -289,7 +264,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("$like operator 2", function() {
var a, result;
a = create();
@@ -300,7 +274,6 @@
});
return equal(result.length, 3);
});
-
test("$likeI operator", function() {
var a, result;
a = create();
@@ -317,7 +290,6 @@
});
return equal(result.length, 1);
});
-
test("$regex", function() {
var a, result;
a = create();
@@ -329,7 +301,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("$regex2", function() {
var a, result;
a = create();
@@ -340,7 +311,6 @@
});
return equal(result.length, 1);
});
-
test("$regex3", function() {
var a, result;
a = create();
@@ -351,7 +321,6 @@
});
return equal(result.length, 3);
});
-
test("$regex4", function() {
var a, result;
a = create();
@@ -360,7 +329,6 @@
});
return equal(result.length, 1);
});
-
test("$cb - callback", function() {
var a, result;
a = create();
@@ -374,7 +342,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});
-
test("$cb - callback - checking 'this' is the model", function() {
var a, result;
a = create();
@@ -388,7 +355,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});
-
test("$and operator", function() {
var a, result;
a = create();
@@ -403,7 +369,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});
-
test("$and operator (explicit)", function() {
var a, result;
a = create();
@@ -420,7 +385,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});
-
test("$or operator", function() {
var a, result;
a = create();
@@ -436,7 +400,6 @@
});
return equal(result.length, 2);
});
-
test("$nor operator", function() {
var a, result;
a = create();
@@ -453,7 +416,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("Compound Queries", function() {
var a, result;
a = create();
@@ -496,7 +458,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});
-
test("Limit", function() {
var a, result;
a = create();
@@ -509,7 +470,6 @@
});
return equal(result.length, 2);
});
-
test("Offset", function() {
var a, result;
a = create();
@@ -523,7 +483,6 @@
});
return equal(result.length, 1);
});
-
test("Page", function() {
var a, result;
a = create();
@@ -537,7 +496,6 @@
});
return equal(result.length, 0);
});
-
test("Sorder by model key", function() {
var a, result;
a = create();
@@ -553,7 +511,6 @@
equal(result[1].get("title"), "Home");
return equal(result[2].get("title"), "Contact");
});
-
test("Sorder by model key with descending order", function() {
var a, result;
a = create();
@@ -570,7 +527,6 @@
equal(result[1].get("title"), "Home");
return equal(result[0].get("title"), "Contact");
});
-
test("Sorder by function", function() {
var a, result;
a = create();
@@ -588,7 +544,6 @@
equal(result[0].get("title"), "Home");
return equal(result[1].get("title"), "Contact");
});
-
test("cache", function() {
var a, result;
a = create();
@@ -637,7 +592,6 @@
});
return equal(result.length, 3);
});
-
test("cache with multiple collections", function() {
var a, a_result, b, b_result;
a = create();
@@ -719,7 +673,6 @@
equal(b_result.length, 2);
return equal(b.length, 1);
});
-
test("null attribute with various operators", function() {
var a, result;
a = create();
@@ -772,5 +725,4 @@
});
return equal(result.length, 0);
});
-
}).call(this);
Please sign in to comment.
Something went wrong with that request. Please try again.