test/helpers: annotate skipped tests

Differentiate between tests skipped by feature flags, and those
manually marked as skipped.

Tests that use the bdd.describe and bdd.it helper functions
will be marked as [UNSUPPORTED] if they are conditionally disabled.
This commit is contained in:
Kevin Delisle 2017-06-05 16:02:53 -04:00
parent 3b45c76d0f
commit 828a71e576
3 changed files with 68 additions and 55 deletions

View File

@ -573,10 +573,12 @@ describe('basic-querying', function() {
}); });
}); });
var itWhenIlikeSupported = connectorCapabilities.ilike ? it : it.skip.bind(it); var itWhenIlikeSupported = connectorCapabilities.ilike;
bdd.describeIf(itWhenIlikeSupported, 'ilike', function() {
itWhenIlikeSupported('should support "like" that is satisfied', function(done) { it('should support "like" that is satisfied',
User.find({where: {name: {like: 'John'}}}, function(err, users) { function(done) {
User.find({where: {name: {like: 'John'}}},
function(err, users) {
if (err) return done(err); if (err) return done(err);
users.length.should.equal(1); users.length.should.equal(1);
users[0].name.should.equal('John Lennon'); users[0].name.should.equal('John Lennon');
@ -584,44 +586,38 @@ describe('basic-querying', function() {
}); });
}); });
itWhenIlikeSupported('should support "like" that is not satisfied', function(done) { it('should support "like" that is not satisfied',
User.find({where: {name: {like: 'Bob'}}}, function(err, users) { function(done) {
User.find({where: {name: {like: 'Bob'}}},
function(err, users) {
if (err) return done(err); if (err) return done(err);
users.length.should.equal(0); users.length.should.equal(0);
done(); done();
}); });
}); });
it('should support "ilike" that is satisfied', function(done) {
var itWhenNilikeSupported = connectorCapabilities.nilike ? it : it.skip.bind(it); User.find({where: {name: {ilike: 'john'}}},
function(err, users) {
itWhenNilikeSupported('should support "nlike" that is satisfied', function(done) {
User.find({where: {name: {nlike: 'John'}}}, function(err, users) {
if (err) return done(err);
users.length.should.equal(5);
users[0].name.should.equal('Paul McCartney');
done();
});
});
itWhenIlikeSupported('should support "ilike" that is satisfied', function(done) {
User.find({where: {name: {ilike: 'john'}}}, function(err, users) {
if (err) return done(err); if (err) return done(err);
users.length.should.equal(1); users.length.should.equal(1);
users[0].name.should.equal('John Lennon'); users[0].name.should.equal('John Lennon');
done(); done();
}); });
}); });
it('should support "ilike" that is not satisfied', function(done) {
itWhenIlikeSupported('should support "ilike" that is not satisfied', function(done) {
User.find({where: {name: {ilike: 'bob'}}}, function(err, users) { User.find({where: {name: {ilike: 'bob'}}}, function(err, users) {
if (err) return done(err); if (err) return done(err);
users.length.should.equal(0); users.length.should.equal(0);
done(); done();
}); });
}); });
});
itWhenNilikeSupported('should support "nilike" that is satisfied', function(done) { var itWhenNilikeSupported = connectorCapabilities.nilike !== false;
User.find({where: {name: {nilike: 'john'}}}, function(err, users) { bdd.describeIf(itWhenNilikeSupported, 'nilike', function() {
it('should support "nlike" that is satisfied', function(done) {
User.find({where: {name: {nlike: 'John'}}},
function(err, users) {
if (err) return done(err); if (err) return done(err);
users.length.should.equal(5); users.length.should.equal(5);
users[0].name.should.equal('Paul McCartney'); users[0].name.should.equal('Paul McCartney');
@ -629,6 +625,17 @@ describe('basic-querying', function() {
}); });
}); });
it('should support "nilike" that is satisfied', function(done) {
User.find({where: {name: {nilike: 'john'}}},
function(err, users) {
if (err) return done(err);
users.length.should.equal(5);
users[0].name.should.equal('Paul McCartney');
done();
});
});
});
describe('geo queries', function() { describe('geo queries', function() {
describe('near filter', function() { describe('near filter', function() {
it('supports a basic "near" query', function(done) { it('supports a basic "near" query', function(done) {
@ -838,8 +845,8 @@ describe('basic-querying', function() {
}); });
}); });
var describeWhenNestedSupported = connectorCapabilities.nestedProperty ? describe : describe.skip; var describeWhenNestedSupported = connectorCapabilities.nestedProperty;
describeWhenNestedSupported('query with nested property', function() { bdd.describeIf(describeWhenNestedSupported, 'query with nested property', function() {
it('should support nested property in query', function(done) { it('should support nested property in query', function(done) {
User.find({where: {'address.city': 'San Jose'}}, function(err, users) { User.find({where: {'address.city': 'San Jose'}}, function(err, users) {
if (err) return done(err); if (err) return done(err);
@ -1030,6 +1037,7 @@ describe('basic-querying', function() {
}); });
}); });
// FIXME: This should either be re-enabled or removed.
describe.skip('queries', function() { describe.skip('queries', function() {
var Todo; var Todo;

View File

@ -4,16 +4,20 @@
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
'use strict'; 'use strict';
var fmt = require('util').format;
exports.describeIf = function describeIf(cond, name, fn) { exports.describeIf = function describeIf(cond, name, fn) {
if (cond) if (cond)
describe(name, fn); describe(name, fn);
else else {
describe.skip(name, fn); describe.skip(fmt('[UNSUPPORTED] - %s', name), fn);
}
}; };
exports.itIf = function itIf(cond, name, fn) { exports.itIf = function itIf(cond, name, fn) {
if (cond) if (cond)
it(name, fn); it(name, fn);
else else {
it.skip(name, fn); it.skip(fmt('[UNSUPPORTED] - %s', name), fn);
}
}; };

View File

@ -21,8 +21,9 @@ var HookMonitor = require('./helpers/hook-monitor');
module.exports = function(dataSource, should, connectorCapabilities) { module.exports = function(dataSource, should, connectorCapabilities) {
if (!connectorCapabilities) connectorCapabilities = {}; if (!connectorCapabilities) connectorCapabilities = {};
if (connectorCapabilities.replaceOrCreateReportsNewInstance === undefined) { if (connectorCapabilities.replaceOrCreateReportsNewInstance === undefined) {
console.warn('The connector does not support a recently added feature:' + var warn = 'The connector does not support a recently added feature:' +
' replaceOrCreateReportsNewInstance'); ' replaceOrCreateReportsNewInstance';
console.warn(warn);
} }
describe('Persistence hooks', function() { describe('Persistence hooks', function() {
var ctxRecorder, hookMonitor, expectedError; var ctxRecorder, hookMonitor, expectedError;