From acc0a71bde387764aeff89f6b0e23b3070fafd8d Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Wed, 19 Dec 2012 18:57:21 +0400 Subject: [PATCH] Update railwayjs name, add ability to skip tests --- lib/railway.js | 2 +- test/common_test.js | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/railway.js b/lib/railway.js index bc54a920..56097aa4 100644 --- a/lib/railway.js +++ b/lib/railway.js @@ -11,7 +11,7 @@ if (global.railway) { module.exports = function init(root) { var railway, app, models; - if (typeof root !== 'object' || root.constructor.name !== 'Railway') { + if (typeof root !== 'object' || root.constructor.name !== 'Compound') { railway = global.railway; app = global.app; models = app.models; diff --git a/test/common_test.js b/test/common_test.js index d2591a79..322f5cf0 100644 --- a/test/common_test.js +++ b/test/common_test.js @@ -33,6 +33,10 @@ function it(name, cases) { batch[schemaName][name] = cases; } +function skip(name) { + delete batch[schemaName][name]; +} + module.exports = function testSchema(exportCasesHere, schema) { batch = exportCasesHere; @@ -69,7 +73,6 @@ module.exports = function testSchema(exportCasesHere, schema) { }; -module.exports.it = it; Object.defineProperty(module.exports, 'it', { writable: true, enumerable: false, @@ -77,6 +80,13 @@ Object.defineProperty(module.exports, 'it', { value: it }); +Object.defineProperty(module.exports, 'skip', { + writable: true, + enumerable: false, + configurable: true, + value: skip +}); + function testOrm(schema) { var requestsAreCounted = schema.name !== 'mongodb'; @@ -101,7 +111,7 @@ function testOrm(schema) { subject: { type: String }, content: { type: Text }, date: { type: Date, default: function () { return new Date }, index: true }, - published: { type: Boolean, default: false }, + published: { type: Boolean, default: false, index: true }, likes: [], related: [RelatedPost] }, {table: 'posts'}); @@ -445,9 +455,10 @@ function testOrm(schema) { it('should find records filtered with multiple attributes', function (test) { - Post.create({title: 'title', content: 'content', published: true, date: 1}, function (err, post) { - Post.all({where: {title: 'title', date: 1}}, function (err, res) { - test.ok(res.length > 0, 'Exact match with string returns dataset'); + var d = new Date; + Post.create({title: 'title', content: 'content', published: true, date: d}, function (err, post) { + Post.all({where: {title: 'title', date: d, published: true}}, function (err, res) { + test.equals(res.length, 1, 'Filtering Posts returns one post'); test.done(); }); });