Upgrade eslint-config-loopback + fix formatting
The new version of our config enabled function-paren-newline rule, this commit fixes the codebase to use more consistent handling of newlines when calling functions.
This commit is contained in:
parent
be7d97c885
commit
7d50f6130b
|
@ -109,8 +109,10 @@ Physician.create({name: 'Dr John'}, function(err, physician1) {
|
|||
patient1.physicians.create({name: 'Dr X'}, function(err, patient4) {
|
||||
console.log('Physician 4: ', patient4, patient4.constructor.modelName);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,7 +43,8 @@ KeyValueMemoryConnector.prototype._setupRegularCleanup = function() {
|
|||
clearInterval(timer);
|
||||
}
|
||||
},
|
||||
1000);
|
||||
1000
|
||||
);
|
||||
this._cleanupTimer.unref();
|
||||
};
|
||||
|
||||
|
|
15
lib/dao.js
15
lib/dao.js
|
@ -135,14 +135,16 @@ function invokeConnectorMethod(connector, method, Model, args, options, cb) {
|
|||
// If the DataSource is a transaction and no transaction object is provide in
|
||||
// the options yet, add it to the options, see: DataSource#transaction()
|
||||
var opts = dataSource.isTransaction && !options.transaction ? Object.assign(
|
||||
options, {transaction: dataSource.currentTransaction}) : options;
|
||||
options, {transaction: dataSource.currentTransaction}
|
||||
) : options;
|
||||
var optionsSupported = connector[method].length >= args.length + 3;
|
||||
var transaction = opts.transaction;
|
||||
if (transaction) {
|
||||
if (!optionsSupported) {
|
||||
return process.nextTick(function() {
|
||||
cb(new Error(g.f(
|
||||
'The connector does not support {{method}} within a transaction', method)));
|
||||
'The connector does not support {{method}} within a transaction', method
|
||||
)));
|
||||
});
|
||||
}
|
||||
// transaction isn't always a Transaction instance. Some tests provide a
|
||||
|
@ -1749,7 +1751,8 @@ DataAccessObject._coerce = function(where, options) {
|
|||
'The %s property has invalid clause %j: Expected precisely 2 values, received %d',
|
||||
p,
|
||||
where[p],
|
||||
val.length));
|
||||
val.length
|
||||
));
|
||||
err.statusCode = 400;
|
||||
throw err;
|
||||
}
|
||||
|
@ -1762,7 +1765,8 @@ DataAccessObject._coerce = function(where, options) {
|
|||
err = new Error(g.f(
|
||||
'The %s property has invalid clause %j: Expected a string or RegExp',
|
||||
p,
|
||||
where[p]));
|
||||
where[p]
|
||||
));
|
||||
err.statusCode = 400;
|
||||
throw err;
|
||||
}
|
||||
|
@ -2998,7 +3002,8 @@ DataAccessObject.replaceById = function(id, data, options, cb) {
|
|||
err = new Error(g.f(
|
||||
'The connector %s does not support {{replaceById}} operation. This is not a bug in LoopBack. ' +
|
||||
'Please contact the authors of the connector, preferably via GitHub issues.',
|
||||
connector.name));
|
||||
connector.name
|
||||
));
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
|
|
|
@ -413,7 +413,8 @@ DataSource.prototype.setup = function(dsName, settings) {
|
|||
console.warn(
|
||||
'A datasource is created with name %j, which is different from the name in settings (%j). ' +
|
||||
'Please adjust your configuration to ensure these names match.',
|
||||
dsName, settings.name);
|
||||
dsName, settings.name
|
||||
);
|
||||
}
|
||||
|
||||
// Disconnected by default
|
||||
|
@ -2339,7 +2340,8 @@ DataSource.prototype.transaction = function(execute, options, cb) {
|
|||
if (!transaction) {
|
||||
process.nextTick(function() {
|
||||
cb(new Error(g.f(
|
||||
'Transaction is not ready, wait for the returned promise to resolve')));
|
||||
'Transaction is not ready, wait for the returned promise to resolve'
|
||||
)));
|
||||
});
|
||||
}
|
||||
return transaction;
|
||||
|
|
|
@ -114,8 +114,8 @@ function preventFkOverride(inst, data, fkProp) {
|
|||
'Cannot override foreign key %s from %s to %s',
|
||||
fkProp,
|
||||
inst[fkProp],
|
||||
data[fkProp])
|
||||
);
|
||||
data[fkProp]
|
||||
));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -1825,7 +1825,8 @@ HasOne.prototype.create = function(targetModelData, options, cb) {
|
|||
} else {
|
||||
cb && cb(new Error(g.f(
|
||||
'{{HasOne}} relation cannot create more than one instance of %s',
|
||||
modelTo.modelName)));
|
||||
modelTo.modelName
|
||||
)));
|
||||
}
|
||||
});
|
||||
return cb.promise;
|
||||
|
|
|
@ -149,8 +149,7 @@ if (Transaction) {
|
|||
// The connection should have been released back the pool
|
||||
this.connection = null;
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
return cb.promise;
|
||||
};
|
||||
|
@ -189,8 +188,7 @@ if (Transaction) {
|
|||
// The connection should have been released back the pool
|
||||
this.connection = null;
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
return cb.promise;
|
||||
};
|
||||
|
|
|
@ -571,7 +571,8 @@ function uniq(a) {
|
|||
}
|
||||
assert(Array.isArray(a), 'array argument is required');
|
||||
var comparableA = a.map(
|
||||
item => item.hasOwnProperty('_bsontype') ? item.toString() : item);
|
||||
item => item.hasOwnProperty('_bsontype') ? item.toString() : item
|
||||
);
|
||||
for (var i = 0, n = comparableA.length; i < n; i++) {
|
||||
if (comparableA.indexOf(comparableA[i]) === i) {
|
||||
uniqArray.push(a[i]);
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
"async-iterators": "^0.2.2",
|
||||
"bson": "^1.0.4",
|
||||
"coveralls": "^3.0.1",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-loopback": "^10.0.0",
|
||||
"eslint": "^5.1.0",
|
||||
"eslint-config-loopback": "^11.0.0",
|
||||
"loopback-connector-throwing": "file:./test/fixtures/loopback-connector-throwing",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "^12.0.2",
|
||||
|
|
|
@ -51,13 +51,15 @@ var operations = [
|
|||
function findOrCreate_found(ds) {
|
||||
return ds.TestModel.findOrCreate(
|
||||
{where: {name: ds.existingInstance.name}},
|
||||
{name: ds.existingInstance.name});
|
||||
{name: ds.existingInstance.name}
|
||||
);
|
||||
},
|
||||
|
||||
function findOrCreate_create(ds) {
|
||||
return ds.TestModel.findOrCreate(
|
||||
{where: {name: 'new-record'}},
|
||||
{name: 'new-record'});
|
||||
{name: 'new-record'}
|
||||
);
|
||||
},
|
||||
|
||||
function updateOrCreate_create(ds) {
|
||||
|
@ -66,7 +68,8 @@ var operations = [
|
|||
|
||||
function updateOrCreate_update(ds) {
|
||||
return ds.TestModel.updateOrCreate(
|
||||
{id: ds.existingInstance.id, name: 'new name'});
|
||||
{id: ds.existingInstance.id, name: 'new name'}
|
||||
);
|
||||
},
|
||||
|
||||
function replaceOrCreate_create(ds) {
|
||||
|
@ -75,13 +78,15 @@ var operations = [
|
|||
|
||||
function replaceOrCreate_update(ds) {
|
||||
return ds.TestModel.replaceOrCreate(
|
||||
{id: ds.existingInstance.id, name: 'new name'});
|
||||
{id: ds.existingInstance.id, name: 'new name'}
|
||||
);
|
||||
},
|
||||
|
||||
function replaceById(ds) {
|
||||
return ds.TestModel.replaceById(
|
||||
ds.existingInstance.id,
|
||||
{name: 'new name'});
|
||||
{name: 'new name'}
|
||||
);
|
||||
},
|
||||
|
||||
function updateAll(ds) {
|
||||
|
|
|
@ -322,7 +322,8 @@ describe('async observer', function() {
|
|||
},
|
||||
function(err) {
|
||||
err.should.eql(testError);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -126,9 +126,11 @@ describe('basic-querying', function() {
|
|||
return u.name;
|
||||
});
|
||||
names.should.eql(
|
||||
[createdUsers[2].name, createdUsers[1].name, createdUsers[0].name]);
|
||||
[createdUsers[2].name, createdUsers[1].name, createdUsers[0].name]
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should query by ids and condition', function(done) {
|
||||
|
|
|
@ -89,7 +89,8 @@ describe('crud-with-options', function() {
|
|||
function(done) {
|
||||
User.findById(undefined, {}, function(err, u) {
|
||||
err.should.be.eql(
|
||||
new Error('Model::findById requires the id argument'));
|
||||
new Error('Model::findById requires the id argument')
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -194,7 +194,8 @@ describe('datatypes', function() {
|
|||
},
|
||||
{
|
||||
persistUndefinedAsNull: true,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
isStrict = TestModel.definition.settings.strict;
|
||||
|
||||
|
|
|
@ -80,7 +80,8 @@ describe('Memory connector with mocked discovery', function() {
|
|||
var s = schemas['STRONGLOOP.INVENTORY'];
|
||||
s.name.should.be.eql('Inventory');
|
||||
Object.keys(s.properties).should.be.eql(
|
||||
['productId', 'locationId', 'available', 'total']);
|
||||
['productId', 'locationId', 'available', 'total']
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -97,7 +98,8 @@ describe('Memory connector with mocked discovery', function() {
|
|||
var s = schemas['STRONGLOOP.INVENTORY'];
|
||||
s.name.should.be.eql('inventory');
|
||||
Object.keys(s.properties).should.be.eql(
|
||||
['product_id', 'location_id', 'available', 'total']);
|
||||
['product_id', 'location_id', 'available', 'total']
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -110,7 +112,8 @@ describe('Memory connector with mocked discovery', function() {
|
|||
var s = schemas['STRONGLOOP.INVENTORY'];
|
||||
s.name.should.be.eql('INVENTORY');
|
||||
Object.keys(s.properties).should.be.eql(
|
||||
['PRODUCT_ID', 'LOCATION_ID', 'AVAILABLE', 'TOTAL']);
|
||||
['PRODUCT_ID', 'LOCATION_ID', 'AVAILABLE', 'TOTAL']
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -411,7 +411,8 @@ describe('hooks', function() {
|
|||
it('should describe isValid sequence', function(done) {
|
||||
should.not.exist(
|
||||
user.constructor._validations,
|
||||
'Expected user to have no validations, but she have');
|
||||
'Expected user to have no validations, but she have'
|
||||
);
|
||||
user.isValid(function(valid) {
|
||||
valid.should.be.true;
|
||||
life.should.eql([
|
||||
|
|
|
@ -1633,8 +1633,7 @@ describe('Model instance with included relation .toJSON()', function() {
|
|||
foreignKey: '',
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
GameParticipationModel = db.createModel('GameParticipation',
|
||||
{
|
||||
date: Date,
|
||||
|
@ -1652,8 +1651,7 @@ describe('Model instance with included relation .toJSON()', function() {
|
|||
foreignKey: '',
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
ResultModel = db.createModel('Result', {
|
||||
points: Number,
|
||||
}, {
|
||||
|
|
|
@ -49,7 +49,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
function(err) {
|
||||
err.message.should.match(/expired-key/);
|
||||
err.should.have.property('statusCode', 404);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('returns error when key does not exist', function() {
|
||||
|
@ -58,7 +59,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
function(err) {
|
||||
err.message.should.match(/key-does-not-exist/);
|
||||
err.should.have.property('statusCode', 404);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function setupCacheItem() {
|
||||
|
|
|
@ -26,7 +26,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
it('gets TTL when key with unexpired TTL exists - Promise API',
|
||||
function() {
|
||||
return Promise.resolve(
|
||||
CacheItem.set('a-key', 'a-value', {ttl: INITIAL_TTL}))
|
||||
CacheItem.set('a-key', 'a-value', {ttl: INITIAL_TTL})
|
||||
)
|
||||
.delay(SMALL_DELAY)
|
||||
.then(function() { return CacheItem.ttl('a-key'); })
|
||||
.then(function(ttl) { ttl.should.be.within(1, INITIAL_TTL); });
|
||||
|
@ -52,7 +53,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
|
||||
it('fails when getting TTL for a key with expired TTL', function() {
|
||||
return Promise.resolve(
|
||||
CacheItem.set('expired-key', 'a-value', {ttl: TTL_PRECISION}))
|
||||
CacheItem.set('expired-key', 'a-value', {ttl: TTL_PRECISION})
|
||||
)
|
||||
.delay(2 * TTL_PRECISION)
|
||||
.then(function() {
|
||||
return CacheItem.ttl('expired-key');
|
||||
|
@ -62,7 +64,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
function(err) {
|
||||
err.message.should.match(/expired-key/);
|
||||
err.should.have.property('statusCode', 404);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('fails when key does not exist', function() {
|
||||
|
@ -71,7 +74,8 @@ module.exports = function(dataSourceFactory, connectorCapabilities) {
|
|||
function(err) {
|
||||
err.message.should.match(/key-does-not-exist/);
|
||||
err.should.have.property('statusCode', 404);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function setupCacheItem() {
|
||||
|
|
|
@ -741,9 +741,11 @@ describe('Model loaded with a base', function() {
|
|||
Customer1.definition.properties.should.have.property('name');
|
||||
Customer2.definition.properties.should.have.property('name');
|
||||
Customer1.definition.properties.name.should.not.be.equal(
|
||||
Customer2.definition.properties.name);
|
||||
Customer2.definition.properties.name
|
||||
);
|
||||
Customer1.definition.properties.name.should.eql(
|
||||
Customer2.definition.properties.name);
|
||||
Customer2.definition.properties.name
|
||||
);
|
||||
});
|
||||
|
||||
it('can remove properties from base model', function() {
|
||||
|
|
|
@ -351,7 +351,8 @@ describe('manipulation', function() {
|
|||
should.equal(result.gender, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
bdd.itIf(connectorCapabilities.refuseDuplicateInsert !== false, 'should refuse to create ' +
|
||||
|
@ -914,8 +915,10 @@ describe('manipulation', function() {
|
|||
should.equal(result.gender, null);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('updates specific instances when PK is not an auto-generated id', function(done) {
|
||||
|
@ -961,7 +964,8 @@ describe('manipulation', function() {
|
|||
function(err, inst) {
|
||||
if (err) return done(err);
|
||||
inst.save(done);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1562,7 +1566,8 @@ describe('manipulation', function() {
|
|||
p.gender.should.equal('male');
|
||||
created.should.equal(false);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should create a record with if new (promise variant)', function(done) {
|
||||
|
@ -1585,7 +1590,8 @@ describe('manipulation', function() {
|
|||
it('should find a record if exists (promise variant)', function(done) {
|
||||
Person.findOrCreate(
|
||||
{where: {name: 'Jed'}},
|
||||
{name: 'Jed', gender: 'male'})
|
||||
{name: 'Jed', gender: 'male'}
|
||||
)
|
||||
.then(function(res) {
|
||||
res.should.be.instanceOf(Array);
|
||||
res.should.have.lengthOf(2);
|
||||
|
@ -2371,7 +2377,8 @@ describe('manipulation', function() {
|
|||
should.equal(result.city, null);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should allow save() of the created instance', function(done) {
|
||||
|
|
|
@ -235,8 +235,7 @@ describe('Model class inheritance', function() {
|
|||
model: 'Order',
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
assert.deepEqual(User.settings, {
|
||||
// forceId is set to 'auto' in memory if idProp.generated && forceId !== false
|
||||
|
|
|
@ -73,7 +73,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, result) {
|
||||
if (err) reject(err);
|
||||
else resolve(result);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, result) {
|
||||
if (err) reject(err);
|
||||
else resolve(result);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ describe('optional-validation', function() {
|
|||
ModelWithForceId = db.createModel(
|
||||
'ModelWithForceId',
|
||||
{name: String},
|
||||
{forceId: true});
|
||||
{forceId: true}
|
||||
);
|
||||
User = db.define('User', {
|
||||
seq: {type: Number, index: true},
|
||||
name: {type: String, index: true, sort: true},
|
||||
|
|
|
@ -109,7 +109,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'loaded',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers the loaded hook multiple times when multiple instances exist', function(done) {
|
||||
|
@ -136,7 +137,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
hookMonitor.names.should.be.empty();
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers the loaded hook multiple times when multiple instances exist when near filter is used',
|
||||
|
@ -242,7 +244,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
hookMonitor.names.should.be.empty();
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should apply updates from `access` hook', function(done) {
|
||||
|
@ -340,7 +343,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
list[0].should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits error when `loaded` hook fails', function(done) {
|
||||
|
@ -350,7 +354,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, list) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -370,7 +375,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('aborts when `after save` fires when option to notify is false', function(done) {
|
||||
|
@ -446,7 +452,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}),
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('validates model after `before save` hook', function(done) {
|
||||
|
@ -474,7 +481,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `persist` hook', function(done) {
|
||||
|
@ -507,7 +515,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `loaded` hook', function(done) {
|
||||
|
@ -529,7 +538,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits error when `loaded` hook fails', function(done) {
|
||||
|
@ -539,7 +549,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `loaded` hook', function(done) {
|
||||
|
@ -560,7 +571,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
instance.should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook', function(done) {
|
||||
|
@ -625,7 +637,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}),
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits `after save` when some models were not saved', function(done) {
|
||||
|
@ -654,7 +667,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: true,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -674,7 +688,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
skip: 0,
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (dataSource.connector.findOrCreate) {
|
||||
|
@ -696,7 +711,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: true,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -717,7 +733,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: true,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('validates model after `before save` hook', function(done) {
|
||||
|
@ -730,7 +747,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
(err || {}).should.be.instanceOf(ValidationError);
|
||||
(err.details.codes || {}).should.eql({name: ['presence']});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks in the correct order when not found', function(done) {
|
||||
|
@ -749,7 +767,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks in the correct order when found', function(done) {
|
||||
|
@ -775,7 +794,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('aborts when `access` hook fails', function(done) {
|
||||
|
@ -787,7 +807,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('aborts when `before save` hook fails', function(done) {
|
||||
|
@ -799,7 +820,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (dataSource.connector.findOrCreate) {
|
||||
|
@ -835,7 +857,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -875,7 +898,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (dataSource.connector.findOrCreate) {
|
||||
|
@ -909,7 +933,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
});
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -948,7 +973,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
});
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (dataSource.connector.findOrCreate) {
|
||||
|
@ -975,7 +1001,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -997,7 +1024,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits error when `loaded` hook fails', function(done) {
|
||||
|
@ -1008,7 +1036,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (dataSource.connector.findOrCreate) {
|
||||
|
@ -1027,7 +1056,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
instance.should.have.property('extra', 'hook data');
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1083,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
instance.should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook when not found', function(done) {
|
||||
|
@ -1073,7 +1104,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: true,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not trigger `after save` hook when found', function(done) {
|
||||
|
@ -1086,7 +1118,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
ctxRecorder.records.should.eql('hook not called');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1131,7 +1164,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook', function(done) {
|
||||
|
@ -1249,7 +1283,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `loaded` hook', function(done) {
|
||||
|
@ -1292,7 +1327,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
// PersistedModel.create and force it to call connector.save()
|
||||
var instance = new TestModel(
|
||||
{id: 'new-id', name: 'created'},
|
||||
{persisted: true});
|
||||
{persisted: true}
|
||||
);
|
||||
|
||||
instance.save(function(err, instance) {
|
||||
if (err) return done(err);
|
||||
|
@ -1348,7 +1384,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook', function(done) {
|
||||
|
@ -1508,7 +1545,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1544,7 +1582,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `loaded` hook updateAttributes', function(done) {
|
||||
|
@ -1625,7 +1664,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook', function(done) {
|
||||
|
@ -1768,7 +1808,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1796,7 +1837,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `loaded` hook replaceAttributes', function(done) {
|
||||
|
@ -1871,7 +1913,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks in the correct order on update', function(done) {
|
||||
|
@ -1889,7 +1932,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `access` hook on create', function(done) {
|
||||
|
@ -1903,7 +1947,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
where: {id: 'not-found'},
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `access` hook on update', function(done) {
|
||||
|
@ -1917,7 +1962,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
where: {id: existingInstance.id},
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not trigger `access` on missing id', function(done) {
|
||||
|
@ -1929,7 +1975,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
ctxRecorder.records.should.equal('hook not called');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `access` hook when found', function(done) {
|
||||
|
@ -1950,7 +1997,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `access` hook when not found', function(done) {
|
||||
|
@ -1972,7 +2020,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks only once', function(done) {
|
||||
|
@ -1989,7 +2038,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
hookMonitor.names.should.eql(['access', 'before save']);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook on update', function(done) {
|
||||
|
@ -2018,7 +2068,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook on create', function(done) {
|
||||
|
@ -2047,7 +2098,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `before save` hook on update', function(done) {
|
||||
|
@ -2063,7 +2115,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
instance.name.should.equal('hooked');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `before save` hook on create', function(done) {
|
||||
|
@ -2083,7 +2136,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
instance.name.should.equal('hooked');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// FIXME(bajtos) this fails with connector-specific updateOrCreate
|
||||
|
@ -2097,7 +2151,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
(err || {}).should.be.instanceOf(ValidationError);
|
||||
(err.details.codes || {}).should.eql({name: ['presence']});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// FIXME(bajtos) this fails with connector-specific updateOrCreate
|
||||
|
@ -2111,7 +2166,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
(err || {}).should.be.instanceOf(ValidationError);
|
||||
(err.details.codes || {}).should.eql({name: ['presence']});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook on create', function(done) {
|
||||
|
@ -2147,7 +2203,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook on update', function(done) {
|
||||
|
@ -2179,7 +2236,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(expectedContext);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `loaded` hook on create', function(done) {
|
||||
|
@ -2205,7 +2263,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
}
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `loaded` hook on update', function(done) {
|
||||
|
@ -2223,7 +2282,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: isNewInstanceFlag ? false : undefined,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits error when `loaded` hook fails', function(done) {
|
||||
|
@ -2233,7 +2293,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook on update', function(done) {
|
||||
|
@ -2252,7 +2313,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: isNewInstanceFlag ? false : undefined,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('aborts when `after save` fires on update or create when option to notify is false', function(done) {
|
||||
|
@ -2282,7 +2344,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
isNewInstance: isNewInstanceFlag ? true : undefined,
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2305,7 +2368,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks in the correct order on replace', function(done) {
|
||||
|
@ -2323,7 +2387,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `access` hook on create', function(done) {
|
||||
|
@ -2337,7 +2402,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
where: {id: 'not-found'},
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `access` hook on replace', function(done) {
|
||||
|
@ -2351,7 +2417,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
where: {id: existingInstance.id},
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not trigger `access` on missing id', function(done) {
|
||||
|
@ -2363,7 +2430,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
ctxRecorder.records.should.equal('hook not called');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `access` hook when found', function(done) {
|
||||
|
@ -2384,7 +2452,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `access` hook when not found', function(done) {
|
||||
|
@ -2406,7 +2475,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers hooks only once', function(done) {
|
||||
|
@ -2423,7 +2493,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
hookMonitor.names.should.eql(['access', 'before save']);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hookon create', function(done) {
|
||||
|
@ -2465,7 +2536,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
ctxRecorder.records.should.eql(expectedContext);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook on create', function(done) {
|
||||
|
@ -2490,7 +2562,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
ctxRecorder.records.should.eql(expectedContext);
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `before save` hook on create', function(done) {
|
||||
|
@ -2505,7 +2578,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
instance.name.should.equal('hooked');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('validates model after `before save` hook on create', function(done) {
|
||||
|
@ -2517,7 +2591,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
(err || {}).should.be.instanceOf(ValidationError);
|
||||
(err.details.codes || {}).should.eql({name: ['presence']});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook on create', function(done) {
|
||||
|
@ -2550,7 +2625,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}
|
||||
ctxRecorder.records.should.eql(expectedContext);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook on replace', function(done) {
|
||||
|
@ -2582,7 +2658,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(expectedContext);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `persist` hook on create', function(done) {
|
||||
|
@ -2608,7 +2685,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
found.should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `persist` hook on update', function(done) {
|
||||
|
@ -2653,7 +2731,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(aCtxForModel(TestModel, expected));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `loaded` hook on replace', function(done) {
|
||||
|
@ -2677,7 +2756,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(aCtxForModel(TestModel, expected));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('emits error when `loaded` hook fails', function(done) {
|
||||
|
@ -2687,7 +2767,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
function(err, instance) {
|
||||
[err].should.eql([expectedError]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook on replace', function(done) {
|
||||
|
@ -2712,7 +2793,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(aCtxForModel(TestModel, expected));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook on create', function(done) {
|
||||
|
@ -2736,7 +2818,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(aCtxForModel(TestModel, expected));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -2761,7 +2844,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
'after save',
|
||||
]);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook', function(done) {
|
||||
|
@ -2801,7 +2885,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
|
||||
ctxRecorder.records.should.eql(expectedContext);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `persist` hook', function(done) {
|
||||
|
@ -2822,7 +2907,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
found.should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -3020,7 +3106,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
TestModel.findById(existingInstance.id, function(err, inst) {
|
||||
if (err) return done(err);
|
||||
(inst ? inst.toObject() : 'null').should.eql(
|
||||
existingInstance.toObject());
|
||||
existingInstance.toObject()
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -3118,7 +3205,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
where: {name: 'searched'},
|
||||
}}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `access` hook', function(done) {
|
||||
|
@ -3140,7 +3228,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `before save` hook', function(done) {
|
||||
|
@ -3156,7 +3245,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
data: {name: 'updated'},
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `before save` hook', function(done) {
|
||||
|
@ -3176,7 +3266,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
instance.should.have.property('extra', 'added');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `persist` hook', function(done) {
|
||||
|
@ -3194,7 +3285,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
}));
|
||||
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('applies updates from `persist` hook', function(done) {
|
||||
|
@ -3212,7 +3304,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
instance.should.have.property('extra', 'hook data');
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('does not trigger `loaded`', function(done) {
|
||||
|
@ -3225,7 +3318,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
if (err) return done(err);
|
||||
ctxRecorder.records.should.eql('hook not called');
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('triggers `after save` hook', function(done) {
|
||||
|
@ -3242,7 +3336,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
info: {count: 1},
|
||||
}));
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts hookState from options', function(done) {
|
||||
|
@ -3258,7 +3353,8 @@ module.exports = function(dataSource, should, connectorCapabilities) {
|
|||
foo: 'bar',
|
||||
});
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2612,7 +2612,8 @@ describe('relations', function() {
|
|||
const actual = pics.map(
|
||||
function(pic) {
|
||||
return {imageName: pic.name, name: pic.imageable().name};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
actual.should.containDeep([
|
||||
{name: 'Article 1', imageName: 'Article Pic'},
|
||||
|
@ -4357,8 +4358,7 @@ describe('relations', function() {
|
|||
Person = db.define('Person', {name: String});
|
||||
Passport = tmp.define('Passport',
|
||||
{name: {type: 'string', required: true}},
|
||||
{idInjection: false}
|
||||
);
|
||||
{idInjection: false});
|
||||
Address = tmp.define('Address', {street: String}, {idInjection: false});
|
||||
Other = db.define('Other', {name: String});
|
||||
Person.embedsOne(Passport, {
|
||||
|
@ -4707,8 +4707,7 @@ describe('relations', function() {
|
|||
db = getMemoryDataSource();
|
||||
Person = db.define('Person', {name: String});
|
||||
Passport = db.define('Passport',
|
||||
{name: {type: 'string', required: true}}
|
||||
);
|
||||
{name: {type: 'string', required: true}});
|
||||
});
|
||||
|
||||
it('can be declared using embedsOne method', function(done) {
|
||||
|
@ -4761,8 +4760,7 @@ describe('relations', function() {
|
|||
{
|
||||
id: {type: 'string', id: true, generated: true},
|
||||
name: {type: 'string', required: true},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('can be declared using embedsOne method', function(done) {
|
||||
|
@ -6163,7 +6161,8 @@ describe('relations', function() {
|
|||
err.name.should.equal('ValidationError');
|
||||
err.details.codes.jobs.should.eql(['uniqueness']);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
bdd.itIf(connectorCapabilities.adhocSort !== false,
|
||||
|
@ -6550,7 +6549,8 @@ describe('relations', function() {
|
|||
type: 'hasMany',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
}).should.throw('Invalid relation name: trigger');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -54,6 +54,7 @@ exports.init = function init(external_exports) {
|
|||
function check_external_exports() {
|
||||
if (!EXT_EXP) throw new Error(
|
||||
'Before run this, please ensure that ' +
|
||||
'require("spec_helper").init(exports); called');
|
||||
'require("spec_helper").init(exports); called'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -347,7 +347,8 @@ describe('validations', function() {
|
|||
if (options.testFlag !== 'someValue') {
|
||||
console.error(
|
||||
'Unexpected validation options: %j Expected %j',
|
||||
options, {testFlag: 'someValue'});
|
||||
options, {testFlag: 'someValue'}
|
||||
);
|
||||
err();
|
||||
}
|
||||
process.nextTick(function() { done(); });
|
||||
|
@ -607,12 +608,14 @@ describe('validations', function() {
|
|||
function createSite1User(next) {
|
||||
SiteUser.create(
|
||||
{siteId: 1, email: EMAIL},
|
||||
next);
|
||||
next
|
||||
);
|
||||
},
|
||||
function createSite2User(user1, next) {
|
||||
SiteUser.create(
|
||||
{siteId: 2, email: EMAIL},
|
||||
next);
|
||||
next
|
||||
);
|
||||
},
|
||||
function validateDuplicateUser(user2, next) {
|
||||
var user3 = new SiteUser({siteId: 1, email: EMAIL});
|
||||
|
@ -1420,7 +1423,8 @@ describe('validations', function() {
|
|||
obj.email = 'test@example.com';
|
||||
var err = givenValidationError('user', obj, 'is invalid');
|
||||
getErrorDetails(err).should.equal(
|
||||
'`user` is invalid (value: { email: \'test@example.com\' }).');
|
||||
'`user` is invalid (value: { email: \'test@example.com\' }).'
|
||||
);
|
||||
});
|
||||
|
||||
function givenValidationError(propertyName, propertyValue, errorMessage) {
|
||||
|
|
Loading…
Reference in New Issue