diff --git a/examples/relations.js b/examples/relations.js index f3c68cbd..858766ea 100644 --- a/examples/relations.js +++ b/examples/relations.js @@ -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); }); - }); - }); + } + ); + } + ); }); }); }); diff --git a/lib/connectors/kv-memory.js b/lib/connectors/kv-memory.js index 7b5a2fb7..2e57a554 100644 --- a/lib/connectors/kv-memory.js +++ b/lib/connectors/kv-memory.js @@ -43,7 +43,8 @@ KeyValueMemoryConnector.prototype._setupRegularCleanup = function() { clearInterval(timer); } }, - 1000); + 1000 + ); this._cleanupTimer.unref(); }; diff --git a/lib/dao.js b/lib/dao.js index dd96799f..65d9fc38 100644 --- a/lib/dao.js +++ b/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); } diff --git a/lib/datasource.js b/lib/datasource.js index 6006eceb..bc144aa0 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -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; diff --git a/lib/relation-definition.js b/lib/relation-definition.js index 9452dc53..398019b2 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -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; diff --git a/lib/transaction.js b/lib/transaction.js index ca323aa2..986a2e1c 100644 --- a/lib/transaction.js +++ b/lib/transaction.js @@ -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; }; diff --git a/lib/utils.js b/lib/utils.js index 4e8d665a..dcd9760b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -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]); diff --git a/package.json b/package.json index 8dc9b90c..676b8a8a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/support/describe-operation-hooks.js b/support/describe-operation-hooks.js index 20aa8119..2812f114 100644 --- a/support/describe-operation-hooks.js +++ b/support/describe-operation-hooks.js @@ -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) { diff --git a/test/async-observer.test.js b/test/async-observer.test.js index b8edff0d..7243ab92 100644 --- a/test/async-observer.test.js +++ b/test/async-observer.test.js @@ -322,7 +322,8 @@ describe('async observer', function() { }, function(err) { err.should.eql(testError); - }); + } + ); }); }); diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index d733ead0..642fdff6 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -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) { diff --git a/test/crud-with-options.test.js b/test/crud-with-options.test.js index 53cffe89..eeb6e2c1 100644 --- a/test/crud-with-options.test.js +++ b/test/crud-with-options.test.js @@ -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(); }); }); diff --git a/test/datatype.test.js b/test/datatype.test.js index 841d83b9..6015e8b1 100644 --- a/test/datatype.test.js +++ b/test/datatype.test.js @@ -194,7 +194,8 @@ describe('datatypes', function() { }, { persistUndefinedAsNull: true, - }); + } + ); isStrict = TestModel.definition.settings.strict; diff --git a/test/discovery.test.js b/test/discovery.test.js index 6fad9286..5a55833a 100644 --- a/test/discovery.test.js +++ b/test/discovery.test.js @@ -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(); }); }); diff --git a/test/hooks.test.js b/test/hooks.test.js index 98352320..41efb0fd 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -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([ diff --git a/test/include.test.js b/test/include.test.js index ee9b2ada..6092bf27 100644 --- a/test/include.test.js +++ b/test/include.test.js @@ -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, }, { diff --git a/test/kvao/expire.suite.js b/test/kvao/expire.suite.js index 6344bd74..7bd00ab2 100644 --- a/test/kvao/expire.suite.js +++ b/test/kvao/expire.suite.js @@ -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() { diff --git a/test/kvao/ttl.suite.js b/test/kvao/ttl.suite.js index bca2b3dd..5bc8d5de 100644 --- a/test/kvao/ttl.suite.js +++ b/test/kvao/ttl.suite.js @@ -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() { diff --git a/test/loopback-dl.test.js b/test/loopback-dl.test.js index 5bb423fb..befc6816 100644 --- a/test/loopback-dl.test.js +++ b/test/loopback-dl.test.js @@ -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() { diff --git a/test/manipulation.test.js b/test/manipulation.test.js index 68ee7d8e..1c4fa7d4 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -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) { diff --git a/test/model-inheritance.test.js b/test/model-inheritance.test.js index cd69d900..baccd347 100644 --- a/test/model-inheritance.test.js +++ b/test/model-inheritance.test.js @@ -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 diff --git a/test/operation-hooks.suite/embeds-many-destroy.suite.js b/test/operation-hooks.suite/embeds-many-destroy.suite.js index 8e91290a..4f4a0c93 100644 --- a/test/operation-hooks.suite/embeds-many-destroy.suite.js +++ b/test/operation-hooks.suite/embeds-many-destroy.suite.js @@ -73,7 +73,8 @@ module.exports = function(dataSource, should, connectorCapabilities) { function(err, result) { if (err) reject(err); else resolve(result); - }); + } + ); }); } diff --git a/test/operation-hooks.suite/embeds-many-update-by-id.suite.js b/test/operation-hooks.suite/embeds-many-update-by-id.suite.js index b7f0314d..c86bf213 100644 --- a/test/operation-hooks.suite/embeds-many-update-by-id.suite.js +++ b/test/operation-hooks.suite/embeds-many-update-by-id.suite.js @@ -74,7 +74,8 @@ module.exports = function(dataSource, should, connectorCapabilities) { function(err, result) { if (err) reject(err); else resolve(result); - }); + } + ); }); } diff --git a/test/optional-validation.test.js b/test/optional-validation.test.js index e1ad5c25..74614280 100644 --- a/test/optional-validation.test.js +++ b/test/optional-validation.test.js @@ -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}, diff --git a/test/persistence-hooks.suite.js b/test/persistence-hooks.suite.js index 8ea0eabe..babc6914 100644 --- a/test/persistence-hooks.suite.js +++ b/test/persistence-hooks.suite.js @@ -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(); - }); + } + ); }); }); diff --git a/test/relations.test.js b/test/relations.test.js index 96d95377..a0951586 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -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'); }); }); diff --git a/test/spec_helper.js b/test/spec_helper.js index 9be024d2..acf9ebcb 100644 --- a/test/spec_helper.js +++ b/test/spec_helper.js @@ -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' + ); } diff --git a/test/validations.test.js b/test/validations.test.js index 181ca4ac..ae0a68a0 100644 --- a/test/validations.test.js +++ b/test/validations.test.js @@ -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) {