Skip to content

Commit

Permalink
fixes broken compound queries test
Browse files Browse the repository at this point in the history
  • Loading branch information
cezary committed Feb 10, 2012
1 parent 3a2f807 commit f994143
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 50 deletions.
6 changes: 4 additions & 2 deletions test/backbone-query-test.coffee
Expand Up @@ -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
Expand Down
48 changes: 0 additions & 48 deletions 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) {
Expand All @@ -23,13 +20,11 @@
};
};
}

if (typeof equal === "undefined" || equal === null) {
equal = function(real, expected) {
return equals.push([real, expected]);
};
}

create = function() {
return new QueryCollection([
{
Expand All @@ -52,7 +47,6 @@
}
]);
};

test("Simple equals query", function() {
var a, result;
a = create();
Expand All @@ -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();
Expand All @@ -71,7 +64,6 @@
});
return equal(result.length, 0);
});

test("Simple equals query with explicit $equal", function() {
var a, result;
a = create();
Expand All @@ -83,7 +75,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("$contains operator", function() {
var a, result;
a = create();
Expand All @@ -94,7 +85,6 @@
});
return equal(result.length, 2);
});

test("$ne operator", function() {
var a, result;
a = create();
Expand All @@ -105,7 +95,6 @@
});
return equal(result.length, 2);
});

test("$lt operator", function() {
var a, result;
a = create();
Expand All @@ -117,7 +106,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("$lte operator", function() {
var a, result;
a = create();
Expand All @@ -128,7 +116,6 @@
});
return equal(result.length, 2);
});

test("$gt operator", function() {
var a, result;
a = create();
Expand All @@ -140,7 +127,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});

test("$gte operator", function() {
var a, result;
a = create();
Expand All @@ -151,7 +137,6 @@
});
return equal(result.length, 2);
});

test("$between operator", function() {
var a, result;
a = create();
Expand All @@ -163,7 +148,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("$in operator", function() {
var a, result;
a = create();
Expand All @@ -174,7 +158,6 @@
});
return equal(result.length, 2);
});

test("$in operator with wrong query value", function() {
var a, result;
a = create();
Expand All @@ -185,7 +168,6 @@
});
return equal(result.length, 0);
});

test("$nin operator", function() {
var a, result;
a = create();
Expand All @@ -197,7 +179,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});

test("$all operator", function() {
var a, result;
a = create();
Expand All @@ -208,7 +189,6 @@
});
return equal(result.length, 2);
});

test("$all operator (wrong values)", function() {
var a, result;
a = create();
Expand All @@ -225,7 +205,6 @@
});
return equal(result.length, 0);
});

test("$any operator", function() {
var a, result;
a = create();
Expand All @@ -242,7 +221,6 @@
});
return equal(result.length, 2);
});

test("$size operator", function() {
var a, result;
a = create();
Expand All @@ -254,7 +232,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});

test("$exists operator", function() {
var a, result;
a = create();
Expand All @@ -265,7 +242,6 @@
});
return equal(result.length, 2);
});

test("$has operator", function() {
var a, result;
a = create();
Expand All @@ -277,7 +253,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Contact");
});

test("$like operator", function() {
var a, result;
a = create();
Expand All @@ -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();
Expand All @@ -300,7 +274,6 @@
});
return equal(result.length, 3);
});

test("$likeI operator", function() {
var a, result;
a = create();
Expand All @@ -317,7 +290,6 @@
});
return equal(result.length, 1);
});

test("$regex", function() {
var a, result;
a = create();
Expand All @@ -329,7 +301,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("$regex2", function() {
var a, result;
a = create();
Expand All @@ -340,7 +311,6 @@
});
return equal(result.length, 1);
});

test("$regex3", function() {
var a, result;
a = create();
Expand All @@ -351,7 +321,6 @@
});
return equal(result.length, 3);
});

test("$regex4", function() {
var a, result;
a = create();
Expand All @@ -360,7 +329,6 @@
});
return equal(result.length, 1);
});

test("$cb - callback", function() {
var a, result;
a = create();
Expand All @@ -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();
Expand All @@ -388,7 +355,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});

test("$and operator", function() {
var a, result;
a = create();
Expand All @@ -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();
Expand All @@ -420,7 +385,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "Home");
});

test("$or operator", function() {
var a, result;
a = create();
Expand All @@ -436,7 +400,6 @@
});
return equal(result.length, 2);
});

test("$nor operator", function() {
var a, result;
a = create();
Expand All @@ -453,7 +416,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("Compound Queries", function() {
var a, result;
a = create();
Expand Down Expand Up @@ -496,7 +458,6 @@
equal(result.length, 1);
return equal(result[0].get("title"), "About");
});

test("Limit", function() {
var a, result;
a = create();
Expand All @@ -509,7 +470,6 @@
});
return equal(result.length, 2);
});

test("Offset", function() {
var a, result;
a = create();
Expand All @@ -523,7 +483,6 @@
});
return equal(result.length, 1);
});

test("Page", function() {
var a, result;
a = create();
Expand All @@ -537,7 +496,6 @@
});
return equal(result.length, 0);
});

test("Sorder by model key", function() {
var a, result;
a = create();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -637,7 +592,6 @@
});
return equal(result.length, 3);
});

test("cache with multiple collections", function() {
var a, a_result, b, b_result;
a = create();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -772,5 +725,4 @@
});
return equal(result.length, 0);
});

}).call(this);

0 comments on commit f994143

Please sign in to comment.