Upgrade eslint-config to 7.x

Also upgrade eslint itself to 3.x.
This commit is contained in:
Miroslav Bajtoš 2017-01-06 13:33:54 +01:00
parent 66c54a9646
commit 454bf93aaf
15 changed files with 94 additions and 94 deletions

View File

@ -2581,7 +2581,7 @@ DataAccessObject.updateAll = function(where, data, options, cb) {
} }
function updateCallback(err, info) { function updateCallback(err, info) {
if (err) return cb (err); if (err) return cb(err);
var context = { var context = {
Model: Model, Model: Model,
@ -2603,7 +2603,7 @@ DataAccessObject.updateAll = function(where, data, options, cb) {
options: options, options: options,
}; };
Model.notifyObserversOf('persist', context, function(err, ctx) { Model.notifyObserversOf('persist', context, function(err, ctx) {
if (err) return cb (err); if (err) return cb(err);
if (connector.update.length === 5) { if (connector.update.length === 5) {
connector.update(Model.modelName, where, data, options, updateCallback); connector.update(Model.modelName, where, data, options, updateCallback);

View File

@ -93,12 +93,12 @@ function lookupModel(models, modelName) {
* @param callback * @param callback
*/ */
function execTasksWithInterLeave(tasks, callback) { function execTasksWithInterLeave(tasks, callback) {
//let's give others some time to process. // let's give others some time to process.
//Context Switch BEFORE Heavy Computation // Context Switch BEFORE Heavy Computation
process.nextTick(function() { process.nextTick(function() {
//Heavy Computation // Heavy Computation
async.parallel(tasks, function(err, info) { async.parallel(tasks, function(err, info) {
//Context Switch AFTER Heavy Computation // Context Switch AFTER Heavy Computation
process.nextTick(function() { process.nextTick(function() {
callback(err, info); callback(err, info);
}); });
@ -274,7 +274,7 @@ Inclusion.include = function(objects, include, options, cb) {
subInclude = scope.include(); subInclude = scope.include();
} else { } else {
subInclude = include[relationName]; subInclude = include[relationName];
//when include = {user:true}, it does not have subInclude // when include = {user:true}, it does not have subInclude
if (subInclude === true) { if (subInclude === true) {
subInclude = null; subInclude = null;
} }
@ -290,11 +290,11 @@ Inclusion.include = function(objects, include, options, cb) {
return; return;
} }
var polymorphic = relation.polymorphic; var polymorphic = relation.polymorphic;
//if (polymorphic && !polymorphic.discriminator) { // if (polymorphic && !polymorphic.discriminator) {
// cb(new Error('Relation "' + relationName + '" is polymorphic but ' + // cb(new Error('Relation "' + relationName + '" is polymorphic but ' +
// 'discriminator is not present')); // 'discriminator is not present'));
// return; // return;
//} // }
if (!relation.modelTo) { if (!relation.modelTo) {
if (!relation.polymorphic) { if (!relation.polymorphic) {
cb(new Error(g.f('{{Relation.modelTo}} is not defined for relation %s and is no {{polymorphic}}', cb(new Error(g.f('{{Relation.modelTo}} is not defined for relation %s and is no {{polymorphic}}',
@ -307,7 +307,7 @@ Inclusion.include = function(objects, include, options, cb) {
if (relation.options.disableInclude) { if (relation.options.disableInclude) {
return cb(); return cb();
} }
//prepare filter and fields for making DB Call // prepare filter and fields for making DB Call
var filter = (scope && scope.conditions()) || {}; var filter = (scope && scope.conditions()) || {};
if ((relation.multiple || relation.type === 'belongsTo') && scope) { if ((relation.multiple || relation.type === 'belongsTo') && scope) {
var includeScope = {}; var includeScope = {};
@ -324,9 +324,9 @@ Inclusion.include = function(objects, include, options, cb) {
} }
utils.mergeQuery(filter, includeScope, {fields: false}); utils.mergeQuery(filter, includeScope, {fields: false});
} }
//Let's add a placeholder where query // Let's add a placeholder where query
filter.where = filter.where || {}; filter.where = filter.where || {};
//if fields are specified, make sure target foreign key is present // if fields are specified, make sure target foreign key is present
var fields = filter.fields; var fields = filter.fields;
if (Array.isArray(fields) && fields.indexOf(relation.keyTo) === -1) { if (Array.isArray(fields) && fields.indexOf(relation.keyTo) === -1) {
fields.push(relation.keyTo); fields.push(relation.keyTo);
@ -339,25 +339,25 @@ Inclusion.include = function(objects, include, options, cb) {
// //
if (relation.multiple) { if (relation.multiple) {
if (relation.modelThrough) { if (relation.modelThrough) {
//hasManyThrough needs separate handling // hasManyThrough needs separate handling
return includeHasManyThrough(cb); return includeHasManyThrough(cb);
} }
//This will also include embedsMany with belongsTo. // This will also include embedsMany with belongsTo.
//Might need to optimize db calls for this. // Might need to optimize db calls for this.
if (relation.type === 'embedsMany') { if (relation.type === 'embedsMany') {
//embedded docs are part of the objects, no need to make db call. // embedded docs are part of the objects, no need to make db call.
//proceed as implemented earlier. // proceed as implemented earlier.
return includeEmbeds(cb); return includeEmbeds(cb);
} }
if (relation.type === 'referencesMany') { if (relation.type === 'referencesMany') {
return includeReferencesMany(cb); return includeReferencesMany(cb);
} }
//This handles exactly hasMany. Fast and straightforward. Without parallel, each and other boilerplate. // This handles exactly hasMany. Fast and straightforward. Without parallel, each and other boilerplate.
if (relation.type === 'hasMany' && relation.multiple && !subInclude) { if (relation.type === 'hasMany' && relation.multiple && !subInclude) {
return includeHasManySimple(cb); return includeHasManySimple(cb);
} }
//assuming all other relations with multiple=true as hasMany // assuming all other relations with multiple=true as hasMany
return includeHasMany(cb); return includeHasMany(cb);
} else { } else {
if (polymorphic) { if (polymorphic) {
@ -369,7 +369,7 @@ Inclusion.include = function(objects, include, options, cb) {
if (relation.type === 'embedsOne') { if (relation.type === 'embedsOne') {
return includeEmbeds(cb); return includeEmbeds(cb);
} }
//hasOne or belongsTo // hasOne or belongsTo
return includeOneToOne(cb); return includeOneToOne(cb);
} }
@ -380,7 +380,7 @@ Inclusion.include = function(objects, include, options, cb) {
*/ */
function includeHasManyThrough(callback) { function includeHasManyThrough(callback) {
var sourceIds = []; var sourceIds = [];
//Map for Indexing objects by their id for faster retrieval // Map for Indexing objects by their id for faster retrieval
var objIdMap = {}; var objIdMap = {};
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
@ -395,8 +395,8 @@ Inclusion.include = function(objects, include, options, cb) {
defineCachedRelations(obj); defineCachedRelations(obj);
obj.__cachedRelations[relationName] = []; obj.__cachedRelations[relationName] = [];
} }
//default filters are not applicable on through model. should be applied // default filters are not applicable on through model. should be applied
//on modelTo later in 2nd DB call. // on modelTo later in 2nd DB call.
var throughFilter = { var throughFilter = {
where: {}, where: {},
}; };
@ -404,8 +404,8 @@ Inclusion.include = function(objects, include, options, cb) {
inq: uniq(sourceIds), inq: uniq(sourceIds),
}; };
if (polymorphic) { if (polymorphic) {
//handle polymorphic hasMany (reverse) in which case we need to filter // handle polymorphic hasMany (reverse) in which case we need to filter
//by discriminator to filter other types // by discriminator to filter other types
throughFilter.where[polymorphic.discriminator] = throughFilter.where[polymorphic.discriminator] =
relation.modelFrom.definition.name; relation.modelFrom.definition.name;
} }
@ -432,24 +432,24 @@ Inclusion.include = function(objects, include, options, cb) {
var throughObj = throughObjs[i]; var throughObj = throughObjs[i];
var targetId = throughObj[relation.keyThrough]; var targetId = throughObj[relation.keyThrough];
if (targetId) { if (targetId) {
//save targetIds for 2nd DB Call // save targetIds for 2nd DB Call
targetIds.push(targetId); targetIds.push(targetId);
var sourceObj = objIdMap[throughObj[relation.keyTo]]; var sourceObj = objIdMap[throughObj[relation.keyTo]];
var targetIdStr = targetId.toString(); var targetIdStr = targetId.toString();
//Since targetId can be duplicates, multiple source objs are put // Since targetId can be duplicates, multiple source objs are put
//into buckets. // into buckets.
var objList = targetObjsMap[targetIdStr] = var objList = targetObjsMap[targetIdStr] =
targetObjsMap[targetIdStr] || []; targetObjsMap[targetIdStr] || [];
objList.push(sourceObj); objList.push(sourceObj);
} }
} }
//Polymorphic relation does not have idKey of modelTo. Find it manually // Polymorphic relation does not have idKey of modelTo. Find it manually
var modelToIdName = idName(relation.modelTo); var modelToIdName = idName(relation.modelTo);
filter.where[modelToIdName] = { filter.where[modelToIdName] = {
inq: uniq(targetIds), inq: uniq(targetIds),
}; };
//make sure that the modelToIdName is included if fields are specified // make sure that the modelToIdName is included if fields are specified
if (Array.isArray(fields) && fields.indexOf(modelToIdName) === -1) { if (Array.isArray(fields) && fields.indexOf(modelToIdName) === -1) {
fields.push(modelToIdName); fields.push(modelToIdName);
} else if (isPlainObject(fields) && !fields[modelToIdName]) { } else if (isPlainObject(fields) && !fields[modelToIdName]) {
@ -468,14 +468,14 @@ Inclusion.include = function(objects, include, options, cb) {
return callback(err); return callback(err);
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes. Call it first as it is an async // simultaneously process subIncludes. Call it first as it is an async
//process. // process.
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
relation.modelTo.include(targets, subInclude, options, next); relation.modelTo.include(targets, subInclude, options, next);
}); });
} }
//process & link each target with object // process & link each target with object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
async.each(targets, linkManyToMany, next); async.each(targets, linkManyToMany, next);
@ -502,7 +502,7 @@ Inclusion.include = function(objects, include, options, cb) {
function includeReferencesMany(callback) { function includeReferencesMany(callback) {
var modelToIdName = idName(relation.modelTo); var modelToIdName = idName(relation.modelTo);
var allTargetIds = []; var allTargetIds = [];
//Map for Indexing objects by their id for faster retrieval // Map for Indexing objects by their id for faster retrieval
var targetObjsMap = {}; var targetObjsMap = {};
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
@ -515,7 +515,7 @@ Inclusion.include = function(objects, include, options, cb) {
// Please note obj is a plain object at this point // Please note obj is a plain object at this point
targetIds = JSON.parse(targetIds); targetIds = JSON.parse(targetIds);
} }
//referencesMany has multiple targetIds per obj. We need to concat // referencesMany has multiple targetIds per obj. We need to concat
// them into allTargetIds before DB Call // them into allTargetIds before DB Call
allTargetIds = allTargetIds.concat(targetIds); allTargetIds = allTargetIds.concat(targetIds);
for (var j = 0; j < targetIds.length; j++) { for (var j = 0; j < targetIds.length; j++) {
@ -550,14 +550,14 @@ Inclusion.include = function(objects, include, options, cb) {
return callback(err); return callback(err);
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes // simultaneously process subIncludes
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
relation.modelTo.include(targets, subInclude, options, next); relation.modelTo.include(targets, subInclude, options, next);
}); });
} }
targets = utils.sortObjectsByIds(modelToIdName, allTargetIds, targets); targets = utils.sortObjectsByIds(modelToIdName, allTargetIds, targets);
//process each target object // process each target object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
async.each(targets, linkManyToMany, next); async.each(targets, linkManyToMany, next);
@ -580,7 +580,7 @@ Inclusion.include = function(objects, include, options, cb) {
* @param callback * @param callback
*/ */
function includeHasManySimple(callback) { function includeHasManySimple(callback) {
//Map for Indexing objects by their id for faster retrieval // Map for Indexing objects by their id for faster retrieval
var objIdMap2 = includeUtils.buildOneToOneIdentityMapWithOrigKeys(objs, relation.keyFrom); var objIdMap2 = includeUtils.buildOneToOneIdentityMapWithOrigKeys(objs, relation.keyFrom);
filter.where[relation.keyTo] = { filter.where[relation.keyTo] = {
@ -612,7 +612,7 @@ Inclusion.include = function(objects, include, options, cb) {
*/ */
function includeHasMany(callback) { function includeHasMany(callback) {
var sourceIds = []; var sourceIds = [];
//Map for Indexing objects by their id for faster retrieval // Map for Indexing objects by their id for faster retrieval
var objIdMap = {}; var objIdMap = {};
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
@ -647,13 +647,13 @@ Inclusion.include = function(objects, include, options, cb) {
return callback(err); return callback(err);
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes // simultaneously process subIncludes
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
relation.modelTo.include(targets, subInclude, options, next); relation.modelTo.include(targets, subInclude, options, next);
}); });
} }
//process each target object // process each target object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
if (targets.length === 0) { if (targets.length === 0) {
@ -664,7 +664,7 @@ Inclusion.include = function(objects, include, options, cb) {
async.each(targets, linkManyToOne, next); async.each(targets, linkManyToOne, next);
function linkManyToOne(target, next) { function linkManyToOne(target, next) {
//fix for bug in hasMany with referencesMany // fix for bug in hasMany with referencesMany
var targetIds = [].concat(target[relation.keyTo]); var targetIds = [].concat(target[relation.keyTo]);
async.each(targetIds, function(targetId, next) { async.each(targetIds, function(targetId, next) {
var obj = objIdMap[targetId.toString()]; var obj = objIdMap[targetId.toString()];
@ -698,7 +698,7 @@ Inclusion.include = function(objects, include, options, cb) {
*/ */
function includePolymorphicBelongsTo(callback) { function includePolymorphicBelongsTo(callback) {
var targetIdsByType = {}; var targetIdsByType = {};
//Map for Indexing objects by their type and targetId for faster retrieval // Map for Indexing objects by their type and targetId for faster retrieval
var targetObjMapByType = {}; var targetObjMapByType = {};
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
@ -714,8 +714,8 @@ Inclusion.include = function(objects, include, options, cb) {
targetIds.push(targetId); targetIds.push(targetId);
var targetIdStr = targetId.toString(); var targetIdStr = targetId.toString();
targetObjsMap[targetIdStr] = targetObjsMap[targetIdStr] || []; targetObjsMap[targetIdStr] = targetObjsMap[targetIdStr] || [];
//Is belongsTo. Multiple objects can have the same // Is belongsTo. Multiple objects can have the same
//targetId and therefore map value is an array // targetId and therefore map value is an array
targetObjsMap[targetIdStr].push(obj); targetObjsMap[targetIdStr].push(obj);
} }
} }
@ -760,13 +760,13 @@ Inclusion.include = function(objects, include, options, cb) {
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes // simultaneously process subIncludes
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
Model.include(targets, subInclude, options, next); Model.include(targets, subInclude, options, next);
}); });
} }
//process each target object // process each target object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
var targetObjsMap = targetObjMapByType[modelType]; var targetObjsMap = targetObjMapByType[modelType];
@ -792,7 +792,7 @@ Inclusion.include = function(objects, include, options, cb) {
*/ */
function includePolymorphicHasOne(callback) { function includePolymorphicHasOne(callback) {
var sourceIds = []; var sourceIds = [];
//Map for Indexing objects by their id for faster retrieval // Map for Indexing objects by their id for faster retrieval
var objIdMap = {}; var objIdMap = {};
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
var obj = objs[i]; var obj = objs[i];
@ -826,13 +826,13 @@ Inclusion.include = function(objects, include, options, cb) {
return callback(err); return callback(err);
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes // simultaneously process subIncludes
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
relation.modelTo.include(targets, subInclude, options, next); relation.modelTo.include(targets, subInclude, options, next);
}); });
} }
//process each target object // process each target object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
async.each(targets, linkOneToOne, next); async.each(targets, linkOneToOne, next);
@ -896,13 +896,13 @@ Inclusion.include = function(objects, include, options, cb) {
return callback(err); return callback(err);
} }
var tasks = []; var tasks = [];
//simultaneously process subIncludes // simultaneously process subIncludes
if (subInclude && targets) { if (subInclude && targets) {
tasks.push(function subIncludesTask(next) { tasks.push(function subIncludesTask(next) {
relation.modelTo.include(targets, subInclude, options, next); relation.modelTo.include(targets, subInclude, options, next);
}); });
} }
//process each target object // process each target object
tasks.push(targetLinkingTask); tasks.push(targetLinkingTask);
function targetLinkingTask(next) { function targetLinkingTask(next) {
async.each(targets, linkOneToMany, next); async.each(targets, linkOneToMany, next);
@ -978,7 +978,7 @@ Inclusion.include = function(objects, include, options, cb) {
cb(null, result); cb(null, result);
} }
//obj.__cachedRelations[relationName] can be null if no data was returned // obj.__cachedRelations[relationName] can be null if no data was returned
if (obj.__cachedRelations && if (obj.__cachedRelations &&
obj.__cachedRelations[relationName] !== undefined) { obj.__cachedRelations[relationName] !== undefined) {
return setIncludeData(obj.__cachedRelations[relationName], return setIncludeData(obj.__cachedRelations[relationName],
@ -987,8 +987,8 @@ Inclusion.include = function(objects, include, options, cb) {
var inst = (obj instanceof self) ? obj : new self(obj); var inst = (obj instanceof self) ? obj : new self(obj);
//If related objects are not cached by include Handlers, directly call // If related objects are not cached by include Handlers, directly call
//related accessor function even though it is not very efficient // related accessor function even though it is not very efficient
var related; // relation accessor function var related; // relation accessor function
if ((relation.multiple || relation.type === 'belongsTo') && scope) { if ((relation.multiple || relation.type === 'belongsTo') && scope) {

View File

@ -898,9 +898,9 @@ var throughKeys = function(definition) {
} else if (definition.modelFrom === definition.modelTo) { } else if (definition.modelFrom === definition.modelTo) {
return findBelongsTo(modelThrough, definition.modelTo, pk2). return findBelongsTo(modelThrough, definition.modelTo, pk2).
sort(function(fk1, fk2) { sort(function(fk1, fk2) {
//Fix for bug - https://github.com/strongloop/loopback-datasource-juggler/issues/571 // Fix for bug - https://github.com/strongloop/loopback-datasource-juggler/issues/571
//Make sure that first key is mapped to modelFrom // Make sure that first key is mapped to modelFrom
//& second key to modelTo. Order matters // & second key to modelTo. Order matters
return (definition.keyTo === fk1) ? -1 : 1; return (definition.keyTo === fk1) ? -1 : 1;
}); });
} else { } else {
@ -1812,7 +1812,7 @@ HasMany.prototype.create = function(targetModelData, options, cb) {
modelTo.create(targetModelData, options, function(err, targetModel) { modelTo.create(targetModelData, options, function(err, targetModel) {
if (!err) { if (!err) {
//Refresh the cache // Refresh the cache
apply(targetModel, self.addToCache.bind(self)); apply(targetModel, self.addToCache.bind(self));
cb && cb(err, targetModel); cb && cb(err, targetModel);
} else { } else {

View File

@ -120,7 +120,7 @@ function convertToArray(include) {
obj[include] = true; obj[include] = true;
return [obj]; return [obj];
} else if (isPlainObject(include)) { } else if (isPlainObject(include)) {
//if include is of the form - {relation:'',scope:''} // if include is of the form - {relation:'',scope:''}
if (include.rel || include.relation) { if (include.rel || include.relation) {
return [include]; return [include];
} }
@ -178,15 +178,15 @@ function mergeQuery(base, update, spec) {
base.include = update.include; base.include = update.include;
} else { } else {
if (spec.nestedInclude === true) { if (spec.nestedInclude === true) {
//specify nestedInclude=true to force nesting of inclusions on scoped // specify nestedInclude=true to force nesting of inclusions on scoped
//queries. e.g. In physician.patients.getAsync({include: 'address'}), // queries. e.g. In physician.patients.getAsync({include: 'address'}),
//inclusion should be on patient model, not on physician model. // inclusion should be on patient model, not on physician model.
var saved = base.include; var saved = base.include;
base.include = {}; base.include = {};
base.include[update.include] = saved; base.include[update.include] = saved;
} else { } else {
//default behaviour of inclusion merge - merge inclusions at the same // default behaviour of inclusion merge - merge inclusions at the same
//level. - https://github.com/strongloop/loopback-datasource-juggler/pull/569#issuecomment-95310874 // level. - https://github.com/strongloop/loopback-datasource-juggler/pull/569#issuecomment-95310874
base.include = mergeIncludes(base.include, update.include); base.include = mergeIncludes(base.include, update.include);
} }
} }

View File

@ -32,8 +32,8 @@
}, },
"devDependencies": { "devDependencies": {
"async-iterators": "^0.2.2", "async-iterators": "^0.2.2",
"eslint": "^3.11.1", "eslint": "^3.12.2",
"eslint-config-loopback": "^6.0.0", "eslint-config-loopback": "^7.0.1",
"mocha": "^2.1.0", "mocha": "^2.1.0",
"should": "^8.0.2" "should": "^8.0.2"
}, },

View File

@ -478,7 +478,7 @@ function testOrm(dataSource) {
/* eslint-disable max-len */ /* eslint-disable max-len */
it('hasMany should be cached', function(test) { it('hasMany should be cached', function(test) {
//User.create(function (e, u) { // User.create(function (e, u) {
// u.posts.create({}, function (e, p) { // u.posts.create({}, function (e, p) {
// find all posts for a user. // find all posts for a user.
// Finding one post with an existing author associated // Finding one post with an existing author associated

View File

@ -3,8 +3,8 @@
// This file is licensed under the MIT License. // This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
/*global describe,it*/ /* global describe,it */
/*jshint expr:true */ /* jshint expr:true */
'use strict'; 'use strict';
@ -44,7 +44,7 @@ describe('GeoPoint', function() {
}); });
it('should reject invalid parameters', function() { it('should reject invalid parameters', function() {
/*jshint -W024 */ /* jshint -W024 */
var fn = function() { var fn = function() {
new GeoPoint('150,-34'); new GeoPoint('150,-34');
}; };

View File

@ -841,11 +841,11 @@ describe('include', function() {
result.forEach(function(r) { result.forEach(function(r) {
assemblies[r.name] = r; assemblies[r.name] = r;
}); });
//sedan // sedan
assemblies.sedan.parts().should.have.length(3); assemblies.sedan.parts().should.have.length(3);
//hatchback // hatchback
assemblies.hatchback.parts().should.have.length(2); assemblies.hatchback.parts().should.have.length(2);
//SUV // SUV
assemblies.SUV.parts().should.have.length(0); assemblies.SUV.parts().should.have.length(0);
self.called.should.eql(3); self.called.should.eql(3);
done(); done();

View File

@ -95,11 +95,11 @@ describe('manipulation', function() {
it('should create instance (promise variant)', function(done) { it('should create instance (promise variant)', function(done) {
Person.create({name: 'Anatoliy'}) Person.create({name: 'Anatoliy'})
.then (function(p) { .then(function(p) {
p.name.should.equal('Anatoliy'); p.name.should.equal('Anatoliy');
should.exist(p); should.exist(p);
return Person.findById(p.id) return Person.findById(p.id)
.then (function(person) { .then(function(person) {
person.id.should.eql(p.id); person.id.should.eql(p.id);
person.name.should.equal('Anatoliy'); person.name.should.equal('Anatoliy');
done(); done();
@ -125,7 +125,7 @@ describe('manipulation', function() {
p.name.should.equal('Anatoliy'); p.name.should.equal('Anatoliy');
p.isNewRecord().should.be.true; p.isNewRecord().should.be.true;
p.save() p.save()
.then (function(inst) { .then(function(inst) {
inst.isNewRecord().should.be.false; inst.isNewRecord().should.be.false;
inst.should.equal(p); inst.should.equal(p);
done(); done();
@ -156,7 +156,7 @@ describe('manipulation', function() {
it('should not allow user-defined value for the id of object - create (promise variant)', function(done) { it('should not allow user-defined value for the id of object - create (promise variant)', function(done) {
Person.create({id: 123456}) Person.create({id: 123456})
.then (function(p) { .then(function(p) {
done(new Error('Person.create should have failed.')); done(new Error('Person.create should have failed.'));
}, function(err) { }, function(err) {
err.should.be.instanceof(ValidationError); err.should.be.instanceof(ValidationError);
@ -184,7 +184,7 @@ describe('manipulation', function() {
var p = new Person({id: 123456}); var p = new Person({id: 123456});
p.isNewRecord().should.be.true; p.isNewRecord().should.be.true;
p.save() p.save()
.then (function(inst) { .then(function(inst) {
done(new Error('save should have failed.')); done(new Error('save should have failed.'));
}, function(err) { }, function(err) {
err.should.be.instanceof(ValidationError); err.should.be.instanceof(ValidationError);
@ -223,11 +223,11 @@ describe('manipulation', function() {
it('should create instance with blank data (promise variant)', function(done) { it('should create instance with blank data (promise variant)', function(done) {
Person.create() Person.create()
.then (function(p) { .then(function(p) {
should.exist(p); should.exist(p);
should.not.exists(p.name); should.not.exists(p.name);
return Person.findById(p.id) return Person.findById(p.id)
.then (function(person) { .then(function(person) {
person.id.should.eql(p.id); person.id.should.eql(p.id);
should.not.exists(person.name); should.not.exists(person.name);
done(); done();

View File

@ -65,12 +65,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
return callCreate().then(function(result) { return callCreate().then(function(result) {
hookMonitor.names.should.eql([ hookMonitor.names.should.eql([
'Embedded:before save', 'Embedded:before save',
//TODO 'Embedded:persist', // TODO 'Embedded:persist',
'Owner:before save', 'Owner:before save',
'Owner:persist', 'Owner:persist',
'Owner:loaded', 'Owner:loaded',
'Owner:after save', 'Owner:after save',
//TODO 'Embedded:loaded', // TODO 'Embedded:loaded',
'Embedded:after save', 'Embedded:after save',
]); ]);
}); });

View File

@ -82,12 +82,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
return callUpdate().then(function(result) { return callUpdate().then(function(result) {
hookMonitor.names.should.eql([ hookMonitor.names.should.eql([
'Embedded:before save', 'Embedded:before save',
//TODO 'Embedded:persist', // TODO 'Embedded:persist',
'Owner:before save', 'Owner:before save',
'Owner:persist', 'Owner:persist',
'Owner:loaded', 'Owner:loaded',
'Owner:after save', 'Owner:after save',
//TODO 'Embedded:loaded', // TODO 'Embedded:loaded',
'Embedded:after save', 'Embedded:after save',
]); ]);
}); });

View File

@ -65,12 +65,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
return callCreate().then(function(result) { return callCreate().then(function(result) {
hookMonitor.names.should.eql([ hookMonitor.names.should.eql([
'Embedded:before save', 'Embedded:before save',
//TODO 'Embedded:persist', // TODO 'Embedded:persist',
'Owner:before save', 'Owner:before save',
'Owner:persist', 'Owner:persist',
'Owner:loaded', 'Owner:loaded',
'Owner:after save', 'Owner:after save',
//TODO 'Embedded:loaded', // TODO 'Embedded:loaded',
'Embedded:after save', 'Embedded:after save',
]); ]);
}); });

View File

@ -72,12 +72,12 @@ module.exports = function(dataSource, should, connectorCapabilities) {
return callUpdate().then(function(result) { return callUpdate().then(function(result) {
hookMonitor.names.should.eql([ hookMonitor.names.should.eql([
'Embedded:before save', 'Embedded:before save',
//TODO 'Embedded:persist', // TODO 'Embedded:persist',
'Owner:before save', 'Owner:before save',
'Owner:persist', 'Owner:persist',
'Owner:loaded', 'Owner:loaded',
'Owner:after save', 'Owner:after save',
//TODO 'Embedded:loaded', // TODO 'Embedded:loaded',
'Embedded:after save', 'Embedded:after save',
]); ]);
}); });

View File

@ -92,9 +92,9 @@ describe('relations', function() {
it('should create record on scope with promises', function(done) { it('should create record on scope with promises', function(done) {
Book.create() Book.create()
.then (function(book) { .then(function(book) {
return book.chapters.create() return book.chapters.create()
.then (function(c) { .then(function(c) {
should.exist(c); should.exist(c);
c.bookId.should.eql(book.id); c.bookId.should.eql(book.id);
done(); done();

View File

@ -338,7 +338,7 @@ describe('util.mergeIncludes', function() {
it('Merge includes with and without relation syntax properly', it('Merge includes with and without relation syntax properly',
function() { function() {
//w & w/o relation syntax - no collision // w & w/o relation syntax - no collision
var baseInclude = ['relation2']; var baseInclude = ['relation2'];
var updateInclude = { var updateInclude = {
relation: 'relation1', relation: 'relation1',
@ -350,14 +350,14 @@ describe('util.mergeIncludes', function() {
}, {relation2: true}]; }, {relation2: true}];
checkInputOutput(baseInclude, updateInclude, expectedInclude); checkInputOutput(baseInclude, updateInclude, expectedInclude);
//w & w/o relation syntax - collision // w & w/o relation syntax - collision
baseInclude = ['relation1']; baseInclude = ['relation1'];
updateInclude = {relation: 'relation1', scope: {include: 'relation2'}}; updateInclude = {relation: 'relation1', scope: {include: 'relation2'}};
expectedInclude = expectedInclude =
[{relation: 'relation1', scope: {include: 'relation2'}}]; [{relation: 'relation1', scope: {include: 'relation2'}}];
checkInputOutput(baseInclude, updateInclude, expectedInclude); checkInputOutput(baseInclude, updateInclude, expectedInclude);
//w & w/o relation syntax - collision // w & w/o relation syntax - collision
baseInclude = {relation: 'relation1', scope: {include: 'relation2'}}; baseInclude = {relation: 'relation1', scope: {include: 'relation2'}};
updateInclude = ['relation1']; updateInclude = ['relation1'];
expectedInclude = [{relation1: true}]; expectedInclude = [{relation1: true}];