不要怂,就是干,撸起袖子干!

Commit 02ea09c7 by Felix Becker Committed by Jan Aagaard Meier

Add arrow-parens rule to ESLint (#7639)

1 parent d2baa896
Showing with 642 additions and 642 deletions
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"space-before-function-paren": ["warn", "never"], "space-before-function-paren": ["warn", "never"],
"keyword-spacing": ["warn"], "keyword-spacing": ["warn"],
"prefer-arrow-callback": "error", "prefer-arrow-callback": "error",
"arrow-parens": ["error", "as-needed"],
"comma-style": ["warn", "last"], "comma-style": ["warn", "last"],
"no-bitwise": "off", "no-bitwise": "off",
"no-cond-assign": ["error", "except-parens"], "no-cond-assign": ["error", "except-parens"],
......
...@@ -113,7 +113,7 @@ SET_IMMEDIATE.prototype.toSql = function(queryGenerator) { ...@@ -113,7 +113,7 @@ SET_IMMEDIATE.prototype.toSql = function(queryGenerator) {
return queryGenerator.setImmediateQuery(this.constraints); return queryGenerator.setImmediateQuery(this.constraints);
}; };
Object.keys(Deferrable).forEach((key) => { Object.keys(Deferrable).forEach(key => {
const DeferrableType = Deferrable[key]; const DeferrableType = Deferrable[key];
DeferrableType.toString = function() { DeferrableType.toString = function() {
......
...@@ -45,7 +45,7 @@ class ConnectionManager { ...@@ -45,7 +45,7 @@ class ConnectionManager {
} }
refreshTypeParser(dataTypes) { refreshTypeParser(dataTypes) {
_.each(dataTypes, (dataType) => { _.each(dataTypes, dataType => {
if (dataType.hasOwnProperty('parse')) { if (dataType.hasOwnProperty('parse')) {
if (dataType.types[this.dialectName]) { if (dataType.types[this.dialectName]) {
this._refreshTypeParser(dataType); this._refreshTypeParser(dataType);
...@@ -84,7 +84,7 @@ class ConnectionManager { ...@@ -84,7 +84,7 @@ class ConnectionManager {
if (!config.replication) { if (!config.replication) {
this.pool = Pooling.createPool({ this.pool = Pooling.createPool({
create: () => new Promise((resolve) => { create: () => new Promise(resolve => {
this this
._connect(config) ._connect(config)
.tap(() => { .tap(() => {
...@@ -98,7 +98,7 @@ class ConnectionManager { ...@@ -98,7 +98,7 @@ class ConnectionManager {
this.poolError = e; this.poolError = e;
}); });
}), }),
destroy: (connection) => { destroy: connection => {
return this._disconnect(connection).tap(() => { return this._disconnect(connection).tap(() => {
debug('connection destroy'); debug('connection destroy');
}); });
...@@ -173,7 +173,7 @@ class ConnectionManager { ...@@ -173,7 +173,7 @@ class ConnectionManager {
read: Pooling.createPool({ read: Pooling.createPool({
create: () => { create: () => {
const nextRead = reads++ % config.replication.read.length; // round robin config const nextRead = reads++ % config.replication.read.length; // round robin config
return new Promise((resolve) => { return new Promise(resolve => {
this this
._connect(config.replication.read[nextRead]) ._connect(config.replication.read[nextRead])
.tap(connection => { .tap(connection => {
...@@ -200,7 +200,7 @@ class ConnectionManager { ...@@ -200,7 +200,7 @@ class ConnectionManager {
idleTimeoutMillis: config.pool.idle idleTimeoutMillis: config.pool.idle
}), }),
write: Pooling.createPool({ write: Pooling.createPool({
create: () => new Promise((resolve) => { create: () => new Promise(resolve => {
this this
._connect(config.replication.write) ._connect(config.replication.write)
.then(connection => { .then(connection => {
......
...@@ -846,7 +846,7 @@ const QueryGenerator = { ...@@ -846,7 +846,7 @@ const QueryGenerator = {
} }
// loop through everything past i and append to the sql // loop through everything past i and append to the sql
collection.slice(i).forEach((collectionItem) => { collection.slice(i).forEach(collectionItem => {
sql += this.quote(collectionItem, parent, connector); sql += this.quote(collectionItem, parent, connector);
}, this); }, this);
......
...@@ -85,7 +85,7 @@ const QueryGenerator = { ...@@ -85,7 +85,7 @@ const QueryGenerator = {
table: this.quoteTable(tableName), table: this.quoteTable(tableName),
attributes: attrStr.join(', ') attributes: attrStr.join(', ')
}, },
pkString = primaryKeys.map((pk) => { return this.quoteIdentifier(pk); }).join(', '); pkString = primaryKeys.map(pk => { return this.quoteIdentifier(pk); }).join(', ');
if (options.uniqueKeys) { if (options.uniqueKeys) {
Utils._.each(options.uniqueKeys, (columns, indexName) => { Utils._.each(options.uniqueKeys, (columns, indexName) => {
...@@ -253,7 +253,7 @@ const QueryGenerator = { ...@@ -253,7 +253,7 @@ const QueryGenerator = {
outputFragment = ' OUTPUT INSERTED.*'; outputFragment = ' OUTPUT INSERTED.*';
} }
Utils._.forEach(attrValueHashes, (attrValueHash) => { Utils._.forEach(attrValueHashes, attrValueHash => {
// special case for empty objects with primary keys // special case for empty objects with primary keys
const fields = Object.keys(attrValueHash); const fields = Object.keys(attrValueHash);
const firstAttr = attributes[fields[0]]; const firstAttr = attributes[fields[0]];
...@@ -278,7 +278,7 @@ const QueryGenerator = { ...@@ -278,7 +278,7 @@ const QueryGenerator = {
}); });
if (allAttributes.length > 0) { if (allAttributes.length > 0) {
Utils._.forEach(attrValueHashes, (attrValueHash) => { Utils._.forEach(attrValueHashes, attrValueHash => {
tuples.push('(' + tuples.push('(' +
allAttributes.map(key => allAttributes.map(key =>
this.escape(attrValueHash[key])).join(',') + this.escape(attrValueHash[key])).join(',') +
...@@ -515,7 +515,7 @@ const QueryGenerator = { ...@@ -515,7 +515,7 @@ const QueryGenerator = {
// enums are a special case // enums are a special case
template = attribute.type.toSql(); template = attribute.type.toSql();
template += ' CHECK (' + this.quoteIdentifier(attribute.field) + ' IN(' + Utils._.map(attribute.values, (value) => { template += ' CHECK (' + this.quoteIdentifier(attribute.field) + ' IN(' + Utils._.map(attribute.values, value => {
return this.escape(value); return this.escape(value);
}).join(', ') + '))'; }).join(', ') + '))';
return template; return template;
......
...@@ -15,7 +15,7 @@ ResourceLock.prototype.lock = function() { ...@@ -15,7 +15,7 @@ ResourceLock.prototype.lock = function() {
const lock = this.previous; const lock = this.previous;
let resolve; let resolve;
this.previous = new Promise((r) => { this.previous = new Promise(r => {
resolve = r; resolve = r;
}); });
......
...@@ -91,7 +91,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -91,7 +91,7 @@ class ConnectionManager extends AbstractConnectionManager {
return new Utils.Promise((resolve, reject) => { return new Utils.Promise((resolve, reject) => {
const connection = this.lib.createConnection(connectionConfig); const connection = this.lib.createConnection(connectionConfig);
const errorHandler = (e) => { const errorHandler = e => {
// clean up connect event if there is error // clean up connect event if there is error
connection.removeListener('connect', connectHandler); connection.removeListener('connect', connectHandler);
reject(e); reject(e);
...@@ -106,7 +106,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -106,7 +106,7 @@ class ConnectionManager extends AbstractConnectionManager {
connection.once('error', errorHandler); connection.once('error', errorHandler);
connection.once('connect', connectHandler); connection.once('connect', connectHandler);
}) })
.then((connection) => { .then(connection => {
if (config.pool.handleDisconnects) { if (config.pool.handleDisconnects) {
// Connection to the MySQL server is usually // Connection to the MySQL server is usually
...@@ -115,7 +115,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -115,7 +115,7 @@ class ConnectionManager extends AbstractConnectionManager {
// server variable configures this) // server variable configures this)
// //
// See [stackoverflow answer](http://stackoverflow.com/questions/20210522/nodejs-mysql-error-connection-lost-the-server-closed-the-connection) // See [stackoverflow answer](http://stackoverflow.com/questions/20210522/nodejs-mysql-error-connection-lost-the-server-closed-the-connection)
connection.on('error', (err) => { connection.on('error', err => {
if (err.code === 'PROTOCOL_CONNECTION_LOST') { if (err.code === 'PROTOCOL_CONNECTION_LOST') {
// Remove it from read/write pool // Remove it from read/write pool
this.pool.destroy(connection); this.pool.destroy(connection);
...@@ -127,19 +127,19 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -127,19 +127,19 @@ class ConnectionManager extends AbstractConnectionManager {
debug('connection acquired'); debug('connection acquired');
return connection; return connection;
}) })
.then((connection) => { .then(connection => {
return new Utils.Promise((resolve, reject) => { return new Utils.Promise((resolve, reject) => {
// set timezone for this connection // set timezone for this connection
// but named timezone are not directly supported in mysql, so get its offset first // but named timezone are not directly supported in mysql, so get its offset first
let tzOffset = this.sequelize.options.timezone; let tzOffset = this.sequelize.options.timezone;
tzOffset = /\//.test(tzOffset) ? momentTz.tz(tzOffset).format('Z') : tzOffset; tzOffset = /\//.test(tzOffset) ? momentTz.tz(tzOffset).format('Z') : tzOffset;
connection.query(`SET time_zone = '${tzOffset}'`, (err) => { connection.query(`SET time_zone = '${tzOffset}'`, err => {
if (err) { reject(err); } else { resolve(connection); } if (err) { reject(err); } else { resolve(connection); }
}); });
}); });
}) })
.catch((err) => { .catch(err => {
if (err.code) { if (err.code) {
switch (err.code) { switch (err.code) {
case 'ECONNREFUSED': case 'ECONNREFUSED':
...@@ -170,7 +170,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -170,7 +170,7 @@ class ConnectionManager extends AbstractConnectionManager {
} }
return new Utils.Promise((resolve, reject) => { return new Utils.Promise((resolve, reject) => {
connection.end((err) => { connection.end(err => {
if (err) { if (err) {
reject(new SequelizeErrors.ConnectionError(err)); reject(new SequelizeErrors.ConnectionError(err));
} else { } else {
......
...@@ -45,7 +45,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -45,7 +45,7 @@ class ConnectionManager extends AbstractConnectionManager {
if (dataType.types.postgres.array_oids) { if (dataType.types.postgres.array_oids) {
for (const oid of dataType.types.postgres.array_oids) { for (const oid of dataType.types.postgres.array_oids) {
this.lib.types.setTypeParser(oid, value => this.lib.types.setTypeParser(oid, value =>
this.lib.types.arrayParser.create(value, (v) => this.lib.types.arrayParser.create(value, v =>
dataType.parse(v, oid, this.lib.types.getTypeParser) dataType.parse(v, oid, this.lib.types.getTypeParser)
).parse() ).parse()
); );
...@@ -123,7 +123,7 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -123,7 +123,7 @@ class ConnectionManager extends AbstractConnectionManager {
}); });
// Don't let a Postgres restart (or error) to take down the whole app // Don't let a Postgres restart (or error) to take down the whole app
connection.on('error', (err) => { connection.on('error', err => {
debug(`connection error ${err.code}`); debug(`connection error ${err.code}`);
connection._invalid = true; connection._invalid = true;
}); });
......
...@@ -195,7 +195,7 @@ class Query extends AbstractQuery { ...@@ -195,7 +195,7 @@ class Query extends AbstractQuery {
m[k.toLowerCase()] = k; m[k.toLowerCase()] = k;
return m; return m;
}, {}); }, {});
rows = _.map(rows, (row)=> { rows = _.map(rows, row=> {
return _.mapKeys(row, (value, key)=> { return _.mapKeys(row, (value, key)=> {
const targetAttr = attrsMap[key]; const targetAttr = attrsMap[key];
if (typeof targetAttr === 'string' && targetAttr !== key) { if (typeof targetAttr === 'string' && targetAttr !== key) {
......
...@@ -59,7 +59,7 @@ exports.hookAliases = hookAliases; ...@@ -59,7 +59,7 @@ exports.hookAliases = hookAliases;
* get array of current hook and its proxied hooks combined * get array of current hook and its proxied hooks combined
* @private * @private
*/ */
const getProxiedHooks = (hookType) => const getProxiedHooks = hookType =>
hookTypes[hookType].proxies hookTypes[hookType].proxies
? hookTypes[hookType].proxies.concat(hookType) ? hookTypes[hookType].proxies.concat(hookType)
: [hookType] : [hookType]
...@@ -67,11 +67,10 @@ const getProxiedHooks = (hookType) => ...@@ -67,11 +67,10 @@ const getProxiedHooks = (hookType) =>
const Hooks = { const Hooks = {
replaceHookAliases(hooks) { replaceHookAliases(hooks) {
let realHookName;
Utils._.each(hooks, (hooksArray, name) => { Utils._.each(hooks, (hooksArray, name) => {
// Does an alias for this hook name exist? // Does an alias for this hook name exist?
if ((realHookName = hookAliases[name])) { const realHookName = hookAliases[name];
if (realHookName) {
// Add the hooks to the actual hook // Add the hooks to the actual hook
hooks[realHookName] = (hooks[realHookName] || []).concat(hooksArray); hooks[realHookName] = (hooks[realHookName] || []).concat(hooksArray);
...@@ -149,7 +148,7 @@ const Hooks = { ...@@ -149,7 +148,7 @@ const Hooks = {
// check for proxies, add them too // check for proxies, add them too
hookType = getProxiedHooks(hookType); hookType = getProxiedHooks(hookType);
Utils._.each(hookType, (type) => { Utils._.each(hookType, type => {
this.options.hooks[type] = this.options.hooks[type] || []; this.options.hooks[type] = this.options.hooks[type] || [];
this.options.hooks[type].push(name ? {name, fn} : fn); this.options.hooks[type].push(name ? {name, fn} : fn);
}); });
......
...@@ -459,7 +459,7 @@ class Model { ...@@ -459,7 +459,7 @@ class Model {
if (include.attributes.length) { if (include.attributes.length) {
_.each(include.model.primaryKeys, (attr, key) => { _.each(include.model.primaryKeys, (attr, key) => {
// Include the primary key if its not already take - take into account that the pk might be aliassed (due to a .field prop) // Include the primary key if its not already take - take into account that the pk might be aliassed (due to a .field prop)
if (!_.some(include.attributes, (includeAttr) => { if (!_.some(include.attributes, includeAttr => {
if (attr.field !== key) { if (attr.field !== key) {
return Array.isArray(includeAttr) && includeAttr[0] === attr.field && includeAttr[1] === key; return Array.isArray(includeAttr) && includeAttr[0] === attr.field && includeAttr[1] === key;
} }
...@@ -1137,7 +1137,7 @@ class Model { ...@@ -1137,7 +1137,7 @@ class Model {
// Assign an auto-generated name to indexes which are not named by the user // Assign an auto-generated name to indexes which are not named by the user
this.options.indexes = this.QueryInterface.nameIndexes(this.options.indexes, this.tableName); this.options.indexes = this.QueryInterface.nameIndexes(this.options.indexes, this.tableName);
indexes = _.filter(this.options.indexes, (item1) => indexes = _.filter(this.options.indexes, item1 =>
!_.some(indexes, item2 => item1.name === item2.name) !_.some(indexes, item2 => item1.name === item2.name)
).sort((index1, index2) => { ).sort((index1, index2) => {
if (this.sequelize.options.dialect === 'postgres') { if (this.sequelize.options.dialect === 'postgres') {
...@@ -2372,7 +2372,7 @@ class Model { ...@@ -2372,7 +2372,7 @@ class Model {
}).then(() => { }).then(() => {
// map fields back to attributes // map fields back to attributes
instances.forEach((instance) => { instances.forEach(instance => {
for (const attr in this.rawAttributes) { for (const attr in this.rawAttributes) {
if (this.rawAttributes[attr].field && if (this.rawAttributes[attr].field &&
instance.dataValues[this.rawAttributes[attr].field] !== undefined && instance.dataValues[this.rawAttributes[attr].field] !== undefined &&
...@@ -2539,7 +2539,7 @@ class Model { ...@@ -2539,7 +2539,7 @@ class Model {
if (options.individualHooks) { if (options.individualHooks) {
return this.findAll({where: options.where, transaction: options.transaction, logging: options.logging, benchmark: options.benchmark, paranoid: false}) return this.findAll({where: options.where, transaction: options.transaction, logging: options.logging, benchmark: options.benchmark, paranoid: false})
.map(instance => this.runHooks('beforeRestore', instance, options).then(() => instance)) .map(instance => this.runHooks('beforeRestore', instance, options).then(() => instance))
.then((_instances) => { .then(_instances => {
instances = _instances; instances = _instances;
}); });
} }
...@@ -3488,7 +3488,7 @@ class Model { ...@@ -3488,7 +3488,7 @@ class Model {
return instance.save(includeOptions).then(() => this[include.association.accessors.set](instance, {save: false, logging: options.logging})); return instance.save(includeOptions).then(() => this[include.association.accessors.set](instance, {save: false, logging: options.logging}));
}); });
}).then(() => { }).then(() => {
const realFields = options.fields.filter((field) => !this.constructor._isVirtualAttribute(field)); const realFields = options.fields.filter(field => !this.constructor._isVirtualAttribute(field));
if (!realFields.length) return this; if (!realFields.length) return this;
if (!this.changed() && !this.isNewRecord) return this; if (!this.changed() && !this.isNewRecord) return this;
......
...@@ -996,7 +996,7 @@ class Sequelize { ...@@ -996,7 +996,7 @@ class Sequelize {
if (!ns) return fn(); if (!ns) return fn();
let res; let res;
ns.run((context) => res = fn(context)); ns.run(context => res = fn(context));
return res; return res;
} }
...@@ -1024,7 +1024,7 @@ class Sequelize { ...@@ -1024,7 +1024,7 @@ class Sequelize {
options = last; options = last;
// remove options from set of logged arguments if options.logging is equal to console.log // remove options from set of logged arguments if options.logging is equal to console.log
if(options.logging === console.log){ if (options.logging === console.log){
args.splice(args.length-1, 1); args.splice(args.length-1, 1);
} }
} else { } else {
......
...@@ -229,7 +229,7 @@ class Transaction { ...@@ -229,7 +229,7 @@ class Transaction {
* @property REPEATABLE_READ * @property REPEATABLE_READ
* @property SERIALIZABLE * @property SERIALIZABLE
*/ */
static get ISOLATION_LEVELS () { static get ISOLATION_LEVELS() {
return { return {
READ_UNCOMMITTED: 'READ UNCOMMITTED', READ_UNCOMMITTED: 'READ UNCOMMITTED',
READ_COMMITTED: 'READ COMMITTED', READ_COMMITTED: 'READ COMMITTED',
......
...@@ -53,7 +53,7 @@ exports.isPrimitive = isPrimitive; ...@@ -53,7 +53,7 @@ exports.isPrimitive = isPrimitive;
// Same concept as _.merge, but don't overwrite properties that have already been assigned // Same concept as _.merge, but don't overwrite properties that have already been assigned
function mergeDefaults(a, b) { function mergeDefaults(a, b) {
return _.mergeWith(a, b, (objectValue) => { return _.mergeWith(a, b, objectValue => {
// If it's an object, let _ handle it this time, we will be called again for each property // If it's an object, let _ handle it this time, we will be called again for each property
if (!this._.isPlainObject(objectValue) && objectValue !== undefined) { if (!this._.isPlainObject(objectValue) && objectValue !== undefined) {
return objectValue; return objectValue;
......
...@@ -16,11 +16,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => { ...@@ -16,11 +16,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 }); return User.create({ id: 1 });
}).then((user) => { }).then(user => {
expect(user.getAssignments).to.be.ok; expect(user.getAssignments).to.be.ok;
return Task.create({ id: 1, userId: 1 }); return Task.create({ id: 1, userId: 1 });
}).then((task) => { }).then(task => {
expect(task.getOwner).to.be.ok; expect(task.getOwner).to.be.ok;
return Promise.all([ return Promise.all([
...@@ -42,11 +42,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => { ...@@ -42,11 +42,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 }); return User.create({ id: 1 });
}).then((user) => { }).then(user => {
expect(user.getASSIGNMENTS).to.be.ok; expect(user.getASSIGNMENTS).to.be.ok;
return Task.create({ id: 1, userId: 1 }); return Task.create({ id: 1, userId: 1 });
}).then((task) => { }).then(task => {
expect(task.getOWNER).to.be.ok; expect(task.getOWNER).to.be.ok;
return Promise.all([ return Promise.all([
...@@ -67,13 +67,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => { ...@@ -67,13 +67,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 }); return User.create({ id: 1 });
}).then((user) => { }).then(user => {
expect(user.getTaskz).to.be.ok; expect(user.getTaskz).to.be.ok;
expect(user.addTask).to.be.ok; expect(user.addTask).to.be.ok;
expect(user.addTaskz).to.be.ok; expect(user.addTaskz).to.be.ok;
}).then(() => { }).then(() => {
return User.find({ where: { id: 1 }, include: [{model: Task, as: 'taskz'}] }); return User.find({ where: { id: 1 }, include: [{model: Task, as: 'taskz'}] });
}).then((user) => { }).then(user => {
expect(user.taskz).to.be.ok; expect(user.taskz).to.be.ok;
}); });
}); });
...@@ -91,13 +91,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => { ...@@ -91,13 +91,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 }); return User.create({ id: 1 });
}).then((user) => { }).then(user => {
expect(user.getAssignments).to.be.ok; expect(user.getAssignments).to.be.ok;
expect(user.addAssignment).to.be.ok; expect(user.addAssignment).to.be.ok;
expect(user.addAssignments).to.be.ok; expect(user.addAssignments).to.be.ok;
}).then(() => { }).then(() => {
return User.find({ where: { id: 1 }, include: [Task] }); return User.find({ where: { id: 1 }, include: [Task] });
}).then((user) => { }).then(user => {
expect(user.assignments).to.be.ok; expect(user.assignments).to.be.ok;
}); });
}); });
......
...@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => { ...@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true required: true
} }
] ]
}).then((tasks) => { }).then(tasks => {
expect(tasks.length).to.be.equal(2); expect(tasks.length).to.be.equal(2);
expect(tasks[0].title).to.be.equal('fight empire'); expect(tasks[0].title).to.be.equal('fight empire');
...@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => { ...@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true required: true
} }
] ]
}).then((tasks) => { }).then(tasks => {
expect(tasks.length).to.be.equal(2); expect(tasks.length).to.be.equal(2);
expect(tasks[0].title).to.be.equal('fight empire'); expect(tasks[0].title).to.be.equal('fight empire');
expect(tasks[1].title).to.be.equal('stablish republic'); expect(tasks[1].title).to.be.equal('stablish republic');
...@@ -173,7 +173,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => { ...@@ -173,7 +173,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true required: true
} }
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.be.equal(1); expect(users.length).to.be.equal(1);
expect(users[0].username).to.be.equal('leia'); expect(users[0].username).to.be.equal('leia');
}); });
...@@ -201,17 +201,17 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => { ...@@ -201,17 +201,17 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
}, { }, {
title: 'empire' title: 'empire'
}]).then(() => { }]).then(() => {
return User.findById(1).then((user) => { return User.findById(1).then(user => {
return Project.findById(1).then((project) => { return Project.findById(1).then(project => {
return user.setProjects([project]).then(() => { return user.setProjects([project]).then(() => {
return User.findById(2).then((user) => { return User.findById(2).then(user => {
return Project.findById(2).then((project) => { return Project.findById(2).then(project => {
return user.setProjects([project]).then(() => { return user.setProjects([project]).then(() => {
return User.findAll({ return User.findAll({
include: [ include: [
{model: Project, where: {title: 'republic'}} {model: Project, where: {title: 'republic'}}
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.be.equal(1); expect(users.length).to.be.equal(1);
expect(users[0].username).to.be.equal('leia'); expect(users[0].username).to.be.equal('leia');
}); });
......
...@@ -108,7 +108,7 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -108,7 +108,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(comment.get('commentable')).to.equal('post'); expect(comment.get('commentable')).to.equal('post');
expect(comment.get('isMain')).to.be.false; expect(comment.get('isMain')).to.be.false;
return this.Post.scope('withMainComment').findById(this.post.get('id')); return this.Post.scope('withMainComment').findById(this.post.get('id'));
}).then((post) => { }).then(post => {
expect(post.mainComment).to.be.null; expect(post.mainComment).to.be.null;
return post.createMainComment({ return post.createMainComment({
title: 'I am a main post comment' title: 'I am a main post comment'
...@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
return this.post.setMainComment(comment); return this.post.setMainComment(comment);
}).then( function() { }).then( function() {
return this.post.getMainComment(); return this.post.getMainComment();
}).then((mainComment) => { }).then(mainComment => {
expect(mainComment.get('commentable')).to.equal('post'); expect(mainComment.get('commentable')).to.equal('post');
expect(mainComment.get('isMain')).to.be.true; expect(mainComment.get('isMain')).to.be.true;
expect(mainComment.get('title')).to.equal('I am a future main comment'); expect(mainComment.get('title')).to.equal('I am a future main comment');
...@@ -167,11 +167,11 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -167,11 +167,11 @@ describe(Support.getTestDialectTeaser('associations'), () => {
); );
}).then(() => { }).then(() => {
return self.Comment.findAll(); return self.Comment.findAll();
}).then((comments) => { }).then(comments => {
comments.forEach((comment) => { comments.forEach(comment => {
expect(comment.get('commentable')).to.be.ok; expect(comment.get('commentable')).to.be.ok;
}); });
expect(comments.map((comment) => { expect(comments.map(comment => {
return comment.get('commentable'); return comment.get('commentable');
}).sort()).to.deep.equal(['image', 'post', 'question']); }).sort()).to.deep.equal(['image', 'post', 'question']);
}).then(function() { }).then(function() {
...@@ -229,7 +229,7 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -229,7 +229,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return self.Post.create(); return self.Post.create();
}).then((post) => { }).then(post => {
return post.createComment({ return post.createComment({
title: 'I am a post comment' title: 'I am a post comment'
}); });
...@@ -503,15 +503,15 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -503,15 +503,15 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(imageTags.length).to.equal(3); expect(imageTags.length).to.equal(3);
expect(questionTags.length).to.equal(3); expect(questionTags.length).to.equal(3);
expect(postTags.map((tag) => { expect(postTags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']); }).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']);
expect(imageTags.map((tag) => { expect(imageTags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']); }).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']);
expect(questionTags.map((tag) => { expect(questionTags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']); }).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']);
}).then(() => { }).then(() => {
...@@ -533,15 +533,15 @@ describe(Support.getTestDialectTeaser('associations'), () => { ...@@ -533,15 +533,15 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(image.tags.length).to.equal(3); expect(image.tags.length).to.equal(3);
expect(question.tags.length).to.equal(3); expect(question.tags.length).to.equal(3);
expect(post.tags.map((tag) => { expect(post.tags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']); }).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']);
expect(image.tags.map((tag) => { expect(image.tags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']); }).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']);
expect(question.tags.map((tag) => { expect(question.tags.map(tag => {
return tag.name; return tag.name;
}).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']); }).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']);
}); });
......
...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Self'), () => { ...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Self'), () => {
return chris.addParent(john); return chris.addParent(john);
}).then(() => { }).then(() => {
return john.getChilds(); return john.getChilds();
}).then((children) => { }).then(children => {
expect(_.map(children, 'id')).to.have.members([mary.id, chris.id]); expect(_.map(children, 'id')).to.have.members([mary.id, chris.id]);
}); });
}); });
......
...@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) { ...@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) {
}); });
}); });
return new Promise((resolve) => { return new Promise(resolve => {
// Wait for the transaction to be setup // Wait for the transaction to be setup
const interval = setInterval(() => { const interval = setInterval(() => {
if (transactionSetup) { if (transactionSetup) {
......
...@@ -61,14 +61,14 @@ describe(Support.getTestDialectTeaser('Configuration'), () => { ...@@ -61,14 +61,14 @@ describe(Support.getTestDialectTeaser('Configuration'), () => {
return Sequelize.Promise.promisify(fs.access)(p, fs.R_OK | fs.W_OK); return Sequelize.Promise.promisify(fs.access)(p, fs.R_OK | fs.W_OK);
} else { // Node v0.10 and older don't have fs.access } else { // Node v0.10 and older don't have fs.access
return Sequelize.Promise.promisify(fs.open)(p, 'r+') return Sequelize.Promise.promisify(fs.open)(p, 'r+')
.then((fd) => { .then(fd => {
return Sequelize.Promise.promisify(fs.close)(fd); return Sequelize.Promise.promisify(fs.close)(fd);
}); });
} }
}); });
return Sequelize.Promise.promisify(fs.unlink)(p) return Sequelize.Promise.promisify(fs.unlink)(p)
.catch((err) => { .catch(err => {
expect(err.code).to.equal('ENOENT'); expect(err.code).to.equal('ENOENT');
}) })
.then(() => { .then(() => {
......
...@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
}); });
it('allows me to return values from a custom parse function', () => { it('allows me to return values from a custom parse function', () => {
const parse = Sequelize.DATE.parse = sinon.spy((value) => { const parse = Sequelize.DATE.parse = sinon.spy(value => {
return moment(value, 'YYYY-MM-DD HH:mm:ss'); return moment(value, 'YYYY-MM-DD HH:mm:ss');
}); });
...@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
}); });
const testSuccess = function(Type, value) { const testSuccess = function(Type, value) {
const parse = Type.constructor.parse = sinon.spy((value) => { const parse = Type.constructor.parse = sinon.spy(value => {
return value; return value;
}); });
...@@ -288,7 +288,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -288,7 +288,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return new Sequelize.Promise((resolve, reject) => { return new Sequelize.Promise((resolve, reject) => {
if (/^postgres/.test(dialect)) { if (/^postgres/.test(dialect)) {
current.query('SELECT PostGIS_Lib_Version();') current.query('SELECT PostGIS_Lib_Version();')
.then((result) => { .then(result => {
if (result[0][0] && semver.lte(result[0][0].postgis_lib_version, '2.1.7')) { if (result[0][0] && semver.lte(result[0][0].postgis_lib_version, '2.1.7')) {
resolve(true); resolve(true);
} else { } else {
...@@ -298,7 +298,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -298,7 +298,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
} else { } else {
resolve(true); resolve(true);
} }
}).then((runTests) => { }).then(runTests => {
if (current.dialect.supports.GEOMETRY && runTests) { if (current.dialect.supports.GEOMETRY && runTests) {
current.refreshTypes(); current.refreshTypes();
...@@ -430,7 +430,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -430,7 +430,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return Model.sync({ force: true }) return Model.sync({ force: true })
.then(() => Model.create({ interval: [1, 4] }) ) .then(() => Model.create({ interval: [1, 4] }) )
.then(() => Model.findAll() ) .then(() => Model.findAll() )
.spread((m) => { .spread(m => {
expect(m.interval[0]).to.be.eql(1); expect(m.interval[0]).to.be.eql(1);
expect(m.interval[1]).to.be.eql(4); expect(m.interval[1]).to.be.eql(4);
}); });
......
...@@ -75,7 +75,7 @@ describe('Connection Manager', () => { ...@@ -75,7 +75,7 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options); const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize); const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise((resolve) => { const resolvedPromise = new Promise(resolve => {
resolve({ resolve({
queryType: 'read' queryType: 'read'
}); });
...@@ -121,7 +121,7 @@ describe('Connection Manager', () => { ...@@ -121,7 +121,7 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options); const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize); const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise((resolve) => { const resolvedPromise = new Promise(resolve => {
resolve({ resolve({
queryType: 'read' queryType: 'read'
}); });
......
...@@ -22,7 +22,7 @@ if (dialect.match(/^mssql/)) { ...@@ -22,7 +22,7 @@ if (dialect.match(/^mssql/)) {
it('should queue concurrent requests to a connection', function() { it('should queue concurrent requests to a connection', function() {
const User = this.User; const User = this.User;
return expect(this.sequelize.transaction((t) => { return expect(this.sequelize.transaction(t => {
return Promise.all([ return Promise.all([
User.findOne({ User.findOne({
transaction: t transaction: t
......
...@@ -81,8 +81,8 @@ if (dialect === 'mysql') { ...@@ -81,8 +81,8 @@ if (dialect === 'mysql') {
self.user = null; self.user = null;
self.task = null; self.task = null;
return self.User.findAll().then((_users) => { return self.User.findAll().then(_users => {
return self.Task.findAll().then((_tasks) => { return self.Task.findAll().then(_tasks => {
self.user = _users[0]; self.user = _users[0];
self.task = _tasks[0]; self.task = _tasks[0];
}); });
...@@ -92,10 +92,10 @@ if (dialect === 'mysql') { ...@@ -92,10 +92,10 @@ if (dialect === 'mysql') {
it('should correctly add an association to the dao', function() { it('should correctly add an association to the dao', function() {
const self = this; const self = this;
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks.length).to.equal(0); expect(_tasks.length).to.equal(0);
return self.user.addTask(self.task).then(() => { return self.user.addTask(self.task).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks.length).to.equal(1); expect(_tasks.length).to.equal(1);
}); });
}); });
...@@ -110,8 +110,8 @@ if (dialect === 'mysql') { ...@@ -110,8 +110,8 @@ if (dialect === 'mysql') {
self.user = null; self.user = null;
self.tasks = null; self.tasks = null;
return self.User.findAll().then((_users) => { return self.User.findAll().then(_users => {
return self.Task.findAll().then((_tasks) => { return self.Task.findAll().then(_tasks => {
self.user = _users[0]; self.user = _users[0];
self.tasks = _tasks; self.tasks = _tasks;
}); });
...@@ -121,16 +121,16 @@ if (dialect === 'mysql') { ...@@ -121,16 +121,16 @@ if (dialect === 'mysql') {
it('should correctly remove associated objects', function() { it('should correctly remove associated objects', function() {
const self = this; const self = this;
return self.user.getTasks().then((__tasks) => { return self.user.getTasks().then(__tasks => {
expect(__tasks.length).to.equal(0); expect(__tasks.length).to.equal(0);
return self.user.setTasks(self.tasks).then(() => { return self.user.setTasks(self.tasks).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks.length).to.equal(self.tasks.length); expect(_tasks.length).to.equal(self.tasks.length);
return self.user.removeTask(self.tasks[0]).then(() => { return self.user.removeTask(self.tasks[0]).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks.length).to.equal(self.tasks.length - 1); expect(_tasks.length).to.equal(self.tasks.length - 1);
return self.user.removeTasks([self.tasks[1], self.tasks[2]]).then(() => { return self.user.removeTasks([self.tasks[1], self.tasks[2]]).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(self.tasks.length - 3); expect(_tasks).to.have.length(self.tasks.length - 3);
}); });
}); });
......
...@@ -45,7 +45,7 @@ if (dialect === 'mysql') { ...@@ -45,7 +45,7 @@ if (dialect === 'mysql') {
// This query will be queued just after the `client.end` is executed and before its callback is called // This query will be queued just after the `client.end` is executed and before its callback is called
return sequelize.query('SELECT COUNT(*) AS count FROM Users', { type: sequelize.QueryTypes.SELECT }); return sequelize.query('SELECT COUNT(*) AS count FROM Users', { type: sequelize.QueryTypes.SELECT });
}) })
.then((count) => { .then(count => {
expect(count[0].count).to.equal(1); expect(count[0].count).to.equal(1);
}); });
}); });
...@@ -67,7 +67,7 @@ if (dialect === 'mysql') { ...@@ -67,7 +67,7 @@ if (dialect === 'mysql') {
// Get next available connection // Get next available connection
return cm.getConnection(); return cm.getConnection();
}) })
.then((connection) => { .then(connection => {
// Old threadId should be different from current new one // Old threadId should be different from current new one
expect(conn.threadId).to.be.equal(connection.threadId); expect(conn.threadId).to.be.equal(connection.threadId);
expect(cm.validate(conn)).to.be.ok; expect(cm.validate(conn)).to.be.ok;
...@@ -84,7 +84,7 @@ if (dialect === 'mysql') { ...@@ -84,7 +84,7 @@ if (dialect === 'mysql') {
return sequelize return sequelize
.sync() .sync()
.then(() => cm.getConnection()) .then(() => cm.getConnection())
.then((connection) => { .then(connection => {
// Save current connection // Save current connection
conn = connection; conn = connection;
// simulate a unexpected end // simulate a unexpected end
...@@ -95,7 +95,7 @@ if (dialect === 'mysql') { ...@@ -95,7 +95,7 @@ if (dialect === 'mysql') {
// Get next available connection // Get next available connection
return cm.getConnection(); return cm.getConnection();
}) })
.then((connection) => { .then(connection => {
// Old threadId should be different from current new one // Old threadId should be different from current new one
expect(conn.threadId).to.not.be.equal(connection.threadId); expect(conn.threadId).to.not.be.equal(connection.threadId);
expect(cm.validate(conn)).to.not.be.ok; expect(cm.validate(conn)).to.not.be.ok;
......
...@@ -69,8 +69,8 @@ if (dialect.match(/^postgres/)) { ...@@ -69,8 +69,8 @@ if (dialect.match(/^postgres/)) {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return self.User.bulkCreate(users).then(() => { return self.User.bulkCreate(users).then(() => {
return self.Task.bulkCreate(tasks).then(() => { return self.Task.bulkCreate(tasks).then(() => {
return self.User.findAll().then((_users) => { return self.User.findAll().then(_users => {
return self.Task.findAll().then((_tasks) => { return self.Task.findAll().then(_tasks => {
self.user = _users[0]; self.user = _users[0];
self.task = _tasks[0]; self.task = _tasks[0];
}); });
...@@ -83,10 +83,10 @@ if (dialect.match(/^postgres/)) { ...@@ -83,10 +83,10 @@ if (dialect.match(/^postgres/)) {
it('should correctly add an association to the dao', function() { it('should correctly add an association to the dao', function() {
const self = this; const self = this;
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(0); expect(_tasks).to.have.length(0);
return self.user.addTask(self.task).then(() => { return self.user.addTask(self.task).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(1); expect(_tasks).to.have.length(1);
}); });
}); });
...@@ -120,23 +120,23 @@ if (dialect.match(/^postgres/)) { ...@@ -120,23 +120,23 @@ if (dialect.match(/^postgres/)) {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return self.User.bulkCreate(users).then(() => { return self.User.bulkCreate(users).then(() => {
return self.Task.bulkCreate(tasks).then(() => { return self.Task.bulkCreate(tasks).then(() => {
return self.User.findAll().then((_users) => { return self.User.findAll().then(_users => {
return self.Task.findAll().then((_tasks) => { return self.Task.findAll().then(_tasks => {
self.user = _users[0]; self.user = _users[0];
self.task = _tasks[0]; self.task = _tasks[0];
self.users = _users; self.users = _users;
self.tasks = _tasks; self.tasks = _tasks;
return self.user.getTasks().then((__tasks) => { return self.user.getTasks().then(__tasks => {
expect(__tasks).to.have.length(0); expect(__tasks).to.have.length(0);
return self.user.setTasks(self.tasks).then(() => { return self.user.setTasks(self.tasks).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(self.tasks.length); expect(_tasks).to.have.length(self.tasks.length);
return self.user.removeTask(self.tasks[0]).then(() => { return self.user.removeTask(self.tasks[0]).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(self.tasks.length - 1); expect(_tasks).to.have.length(self.tasks.length - 1);
return self.user.removeTasks([self.tasks[1], self.tasks[2]]).then(() => { return self.user.removeTasks([self.tasks[1], self.tasks[2]]).then(() => {
return self.user.getTasks().then((_tasks) => { return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(self.tasks.length - 3); expect(_tasks).to.have.length(self.tasks.length - 3);
}); });
}); });
......
...@@ -15,7 +15,7 @@ if (dialect.match(/^postgres/)) { ...@@ -15,7 +15,7 @@ if (dialect.match(/^postgres/)) {
const tzTable = sequelize.define('tz_table', { foo: DataTypes.STRING }); const tzTable = sequelize.define('tz_table', { foo: DataTypes.STRING });
return tzTable.sync({force: true}).then(() => { return tzTable.sync({force: true}).then(() => {
return tzTable.create({foo: 'test'}).then((row) => { return tzTable.create({foo: 'test'}).then(row => {
expect(row).to.be.not.null; expect(row).to.be.not.null;
}); });
}); });
......
...@@ -959,19 +959,19 @@ if (dialect.match(/^postgres/)) { ...@@ -959,19 +959,19 @@ if (dialect.match(/^postgres/)) {
.then(() => { .then(() => {
return Promise.all([ return Promise.all([
this.Student.findById(1) this.Student.findById(1)
.then((Harry) => { .then(Harry => {
return Harry.setClasses([1, 2, 3]); return Harry.setClasses([1, 2, 3]);
}), }),
this.Student.findById(2) this.Student.findById(2)
.then((Ron) => { .then(Ron => {
return Ron.setClasses([1, 2]); return Ron.setClasses([1, 2]);
}), }),
this.Student.findById(3) this.Student.findById(3)
.then((Ginny) => { .then(Ginny => {
return Ginny.setClasses([2, 3]); return Ginny.setClasses([2, 3]);
}), }),
this.Student.findById(4) this.Student.findById(4)
.then((Hermione) => { .then(Hermione => {
return Hermione.setClasses([1, 2, 3]); return Hermione.setClasses([1, 2, 3]);
}) })
]); ]);
...@@ -995,7 +995,7 @@ if (dialect.match(/^postgres/)) { ...@@ -995,7 +995,7 @@ if (dialect.match(/^postgres/)) {
] ]
}); });
}) })
.then((professors) => { .then(professors => {
expect(professors.length).to.eql(2); expect(professors.length).to.eql(2);
expect(professors[0].fullName).to.eql('Albus Dumbledore'); expect(professors[0].fullName).to.eql('Albus Dumbledore');
expect(professors[0].Classes.length).to.eql(1); expect(professors[0].Classes.length).to.eql(1);
......
...@@ -24,7 +24,7 @@ if (dialect === 'sqlite') { ...@@ -24,7 +24,7 @@ if (dialect === 'sqlite') {
return this.User.sync({ force: true }); return this.User.sync({ force: true });
}); });
storages.forEach((storage) => { storages.forEach(storage => {
describe('with storage "' + storage + '"', () => { describe('with storage "' + storage + '"', () => {
after(() => { after(() => {
if (storage === dbFile) { if (storage === dbFile) {
...@@ -35,13 +35,13 @@ if (dialect === 'sqlite') { ...@@ -35,13 +35,13 @@ if (dialect === 'sqlite') {
describe('create', () => { describe('create', () => {
it('creates a table entry', function() { it('creates a table entry', function() {
const self = this; const self = this;
return this.User.create({ age: 21, name: 'John Wayne', bio: 'noot noot' }).then((user) => { return this.User.create({ age: 21, name: 'John Wayne', bio: 'noot noot' }).then(user => {
expect(user.age).to.equal(21); expect(user.age).to.equal(21);
expect(user.name).to.equal('John Wayne'); expect(user.name).to.equal('John Wayne');
expect(user.bio).to.equal('noot noot'); expect(user.bio).to.equal('noot noot');
return self.User.findAll().then((users) => { return self.User.findAll().then(users => {
const usernames = users.map((user) => { const usernames = users.map(user => {
return user.name; return user.name;
}); });
expect(usernames).to.contain('John Wayne'); expect(usernames).to.contain('John Wayne');
...@@ -61,7 +61,7 @@ if (dialect === 'sqlite') { ...@@ -61,7 +61,7 @@ if (dialect === 'sqlite') {
return Person.create({ return Person.create({
name: 'John Doe', name: 'John Doe',
options options
}).then((people) => { }).then(people => {
expect(people.options).to.deep.equal(options); expect(people.options).to.deep.equal(options);
}); });
}); });
...@@ -77,7 +77,7 @@ if (dialect === 'sqlite') { ...@@ -77,7 +77,7 @@ if (dialect === 'sqlite') {
return Person.create({ return Person.create({
name: 'John Doe', name: 'John Doe',
has_swag: true has_swag: true
}).then((people) => { }).then(people => {
expect(people.has_swag).to.be.ok; expect(people.has_swag).to.be.ok;
}); });
}); });
...@@ -93,7 +93,7 @@ if (dialect === 'sqlite') { ...@@ -93,7 +93,7 @@ if (dialect === 'sqlite') {
return Person.create({ return Person.create({
name: 'John Doe', name: 'John Doe',
has_swag: false has_swag: false
}).then((people) => { }).then(people => {
expect(people.has_swag).to.not.be.ok; expect(people.has_swag).to.not.be.ok;
}); });
}); });
...@@ -106,13 +106,13 @@ if (dialect === 'sqlite') { ...@@ -106,13 +106,13 @@ if (dialect === 'sqlite') {
}); });
it('finds normal lookups', function() { it('finds normal lookups', function() {
return this.User.find({ where: { name: 'user' } }).then((user) => { return this.User.find({ where: { name: 'user' } }).then(user => {
expect(user.name).to.equal('user'); expect(user.name).to.equal('user');
}); });
}); });
it.skip('should make aliased attributes available', function() { it.skip('should make aliased attributes available', function() {
return this.User.find({ where: { name: 'user' }, attributes: ['id', ['name', 'username']] }).then((user) => { return this.User.find({ where: { name: 'user' }, attributes: ['id', ['name', 'username']] }).then(user => {
expect(user.username).to.equal('user'); expect(user.username).to.equal('user');
}); });
}); });
...@@ -127,7 +127,7 @@ if (dialect === 'sqlite') { ...@@ -127,7 +127,7 @@ if (dialect === 'sqlite') {
}); });
it('should return all users', function() { it('should return all users', function() {
return this.User.findAll().then((users) => { return this.User.findAll().then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
}); });
}); });
...@@ -143,7 +143,7 @@ if (dialect === 'sqlite') { ...@@ -143,7 +143,7 @@ if (dialect === 'sqlite') {
} }
return this.User.bulkCreate(users).then(() => { return this.User.bulkCreate(users).then(() => {
return self.User.min('age').then((min) => { return self.User.min('age').then(min => {
expect(min).to.equal(2); expect(min).to.equal(2);
}); });
}); });
...@@ -160,7 +160,7 @@ if (dialect === 'sqlite') { ...@@ -160,7 +160,7 @@ if (dialect === 'sqlite') {
} }
return this.User.bulkCreate(users).then(() => { return this.User.bulkCreate(users).then(() => {
return self.User.max('age').then((min) => { return self.User.max('age').then(min => {
expect(min).to.equal(5); expect(min).to.equal(5);
}); });
}); });
......
...@@ -184,7 +184,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), () => { ...@@ -184,7 +184,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), () => {
type: 'ValidationError', type: 'ValidationError',
exception: Sequelize.ValidationError exception: Sequelize.ValidationError
} }
].forEach((constraintTest) => { ].forEach(constraintTest => {
it('Can be intercepted as ' + constraintTest.type + ' using .catch', function() { it('Can be intercepted as ' + constraintTest.type + ' using .catch', function() {
const spy = sinon.spy(), const spy = sinon.spy(),
......
...@@ -111,18 +111,18 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -111,18 +111,18 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return Promise.resolve(); return Promise.resolve();
}); });
this.User.beforeCreate((user) => { this.User.beforeCreate(user => {
user.beforeHookTest = true; user.beforeHookTest = true;
return Promise.resolve(); return Promise.resolve();
}); });
this.User.afterCreate((user) => { this.User.afterCreate(user => {
user.username = 'User' + user.id; user.username = 'User' + user.id;
return Promise.resolve(); return Promise.resolve();
}); });
return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).then((records) => { return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).then(records => {
records.forEach((record) => { records.forEach(record => {
expect(record.username).to.equal('User' + record.id); expect(record.username).to.equal('User' + record.id);
expect(record.beforeHookTest).to.be.true; expect(record.beforeHookTest).to.be.true;
}); });
...@@ -149,12 +149,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -149,12 +149,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return Promise.reject(new Error('You shall not pass!')); return Promise.reject(new Error('You shall not pass!'));
}); });
this.User.afterCreate((user) => { this.User.afterCreate(user => {
user.username = 'User' + user.id; user.username = 'User' + user.id;
return Promise.resolve(); return Promise.resolve();
}); });
return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).catch((err) => { return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).catch(err => {
expect(err).to.be.instanceOf(Error); expect(err).to.be.instanceOf(Error);
expect(beforeBulkCreate).to.be.true; expect(beforeBulkCreate).to.be.true;
expect(afterBulkCreate).to.be.false; expect(afterBulkCreate).to.be.false;
...@@ -246,12 +246,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -246,12 +246,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.afterBulkUpdate(afterBulk); this.User.afterBulkUpdate(afterBulk);
this.User.beforeUpdate((user) => { this.User.beforeUpdate(user => {
expect(user.changed()).to.not.be.empty; expect(user.changed()).to.not.be.empty;
user.beforeHookTest = true; user.beforeHookTest = true;
}); });
this.User.afterUpdate((user) => { this.User.afterUpdate(user => {
user.username = 'User' + user.id; user.username = 'User' + user.id;
}); });
...@@ -259,7 +259,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -259,7 +259,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
{aNumber: 1}, {aNumber: 1}, {aNumber: 1} {aNumber: 1}, {aNumber: 1}, {aNumber: 1}
]).then(() => { ]).then(() => {
return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).spread((affectedRows, records) => { return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).spread((affectedRows, records) => {
records.forEach((record) => { records.forEach(record => {
expect(record.username).to.equal('User' + record.id); expect(record.username).to.equal('User' + record.id);
expect(record.beforeHookTest).to.be.true; expect(record.beforeHookTest).to.be.true;
}); });
...@@ -272,7 +272,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -272,7 +272,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('should run the after/before functions for each item created successfully changing some data before updating', function() { it('should run the after/before functions for each item created successfully changing some data before updating', function() {
const self = this; const self = this;
this.User.beforeUpdate((user) => { this.User.beforeUpdate(user => {
expect(user.changed()).to.not.be.empty; expect(user.changed()).to.not.be.empty;
if (user.get('id') === 1) { if (user.get('id') === 1) {
user.set('aNumber', user.get('aNumber') + 3); user.set('aNumber', user.get('aNumber') + 3);
...@@ -283,7 +283,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -283,7 +283,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
{aNumber: 1}, {aNumber: 1}, {aNumber: 1} {aNumber: 1}, {aNumber: 1}, {aNumber: 1}
]).then(() => { ]).then(() => {
return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).spread((affectedRows, records) => { return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).spread((affectedRows, records) => {
records.forEach((record) => { records.forEach(record => {
expect(record.aNumber).to.equal(10 + (record.id === 1 ? 3 : 0)); expect(record.aNumber).to.equal(10 + (record.id === 1 ? 3 : 0));
}); });
}); });
...@@ -303,12 +303,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -303,12 +303,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('You shall not pass!'); throw new Error('You shall not pass!');
}); });
this.User.afterUpdate((user) => { this.User.afterUpdate(user => {
user.username = 'User' + user.id; user.username = 'User' + user.id;
}); });
return this.User.bulkCreate([{aNumber: 1}, {aNumber: 1}, {aNumber: 1}], { fields: ['aNumber'] }).then(() => { return this.User.bulkCreate([{aNumber: 1}, {aNumber: 1}, {aNumber: 1}], { fields: ['aNumber'] }).then(() => {
return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).catch((err) => { return self.User.update({aNumber: 10}, {where: {aNumber: 1}, individualHooks: true}).catch(err => {
expect(err).to.be.instanceOf(Error); expect(err).to.be.instanceOf(Error);
expect(err.message).to.be.equal('You shall not pass!'); expect(err.message).to.be.equal('You shall not pass!');
expect(beforeBulk).to.have.been.calledOnce; expect(beforeBulk).to.have.been.calledOnce;
...@@ -440,7 +440,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -440,7 +440,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
return this.User.bulkCreate([{aNumber: 1}, {aNumber: 1}, {aNumber: 1}], { fields: ['aNumber'] }).then(() => { return this.User.bulkCreate([{aNumber: 1}, {aNumber: 1}, {aNumber: 1}], { fields: ['aNumber'] }).then(() => {
return self.User.destroy({where: {aNumber: 1}, individualHooks: true}).catch((err) => { return self.User.destroy({where: {aNumber: 1}, individualHooks: true}).catch(err => {
expect(err).to.be.instanceOf(Error); expect(err).to.be.instanceOf(Error);
expect(beforeBulk).to.be.true; expect(beforeBulk).to.be.true;
expect(beforeHook).to.be.true; expect(beforeHook).to.be.true;
...@@ -555,7 +555,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -555,7 +555,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return self.ParanoidUser.destroy({where: {aNumber: 1}}); return self.ParanoidUser.destroy({where: {aNumber: 1}});
}).then(() => { }).then(() => {
return self.ParanoidUser.restore({where: {aNumber: 1}, individualHooks: true}); return self.ParanoidUser.restore({where: {aNumber: 1}, individualHooks: true});
}).catch((err) => { }).catch(err => {
expect(err).to.be.instanceOf(Error); expect(err).to.be.instanceOf(Error);
expect(beforeBulk).to.have.been.calledOnce; expect(beforeBulk).to.have.been.calledOnce;
expect(beforeHook).to.have.been.calledThrice; expect(beforeHook).to.have.been.calledThrice;
......
...@@ -37,14 +37,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -37,14 +37,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
beforeHook = true; beforeHook = true;
}); });
return this.User.count().then((count) => { return this.User.count().then(count => {
expect(count).to.equal(3); expect(count).to.equal(3);
expect(beforeHook).to.be.true; expect(beforeHook).to.be.true;
}); });
}); });
it('beforeCount hook can change options', function() { it('beforeCount hook can change options', function() {
this.User.beforeCount((options) => { this.User.beforeCount(options => {
options.where.username = 'adam'; options.where.username = 'adam';
}); });
......
...@@ -126,12 +126,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -126,12 +126,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeValidate', function(){ it('beforeValidate', function(){
let hookCalled = 0; let hookCalled = 0;
this.User.beforeValidate((user) => { this.User.beforeValidate(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({mood: 'sad', username: 'leafninja'}).then((user) => { return this.User.create({mood: 'sad', username: 'leafninja'}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('leafninja'); expect(user.username).to.equal('leafninja');
expect(hookCalled).to.equal(1); expect(hookCalled).to.equal(1);
...@@ -141,12 +141,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -141,12 +141,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('afterValidate', function() { it('afterValidate', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.afterValidate((user) => { this.User.afterValidate(user => {
user.mood = 'neutral'; user.mood = 'neutral';
hookCalled++; hookCalled++;
}); });
return this.User.create({mood: 'sad', username: 'fireninja'}).then((user) => { return this.User.create({mood: 'sad', username: 'fireninja'}).then(user => {
expect(user.mood).to.equal('neutral'); expect(user.mood).to.equal('neutral');
expect(user.username).to.equal('fireninja'); expect(user.username).to.equal('fireninja');
expect(hookCalled).to.equal(1); expect(hookCalled).to.equal(1);
...@@ -156,12 +156,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -156,12 +156,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeCreate', function() { it('beforeCreate', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.beforeCreate((user) => { this.User.beforeCreate(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({username: 'akira'}).then((user) => { return this.User.create({username: 'akira'}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('akira'); expect(user.username).to.equal('akira');
expect(hookCalled).to.equal(1); expect(hookCalled).to.equal(1);
...@@ -171,12 +171,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -171,12 +171,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave', function() { it('beforeSave', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.beforeSave((user) => { this.User.beforeSave(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({username: 'akira'}).then((user) => { return this.User.create({username: 'akira'}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('akira'); expect(user.username).to.equal('akira');
expect(hookCalled).to.equal(1); expect(hookCalled).to.equal(1);
...@@ -186,17 +186,17 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -186,17 +186,17 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave with beforeCreate', function() { it('beforeSave with beforeCreate', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.beforeCreate((user) => { this.User.beforeCreate(user => {
user.mood = 'sad'; user.mood = 'sad';
hookCalled++; hookCalled++;
}); });
this.User.beforeSave((user) => { this.User.beforeSave(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({username: 'akira'}).then((user) => { return this.User.create({username: 'akira'}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('akira'); expect(user.username).to.equal('akira');
expect(hookCalled).to.equal(2); expect(hookCalled).to.equal(2);
......
...@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeDestroy(beforeHook); this.User.beforeDestroy(beforeHook);
this.User.afterDestroy(afterHook); this.User.afterDestroy(afterHook);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce; expect(afterHook).to.have.been.calledOnce;
...@@ -50,7 +50,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -50,7 +50,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
this.User.afterDestroy(afterHook); this.User.afterDestroy(afterHook);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return expect(user.destroy()).to.be.rejected.then(() => { return expect(user.destroy()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).not.to.have.been.called; expect(afterHook).not.to.have.been.called;
...@@ -68,7 +68,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -68,7 +68,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Whoops!'); throw new Error('Whoops!');
}); });
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return expect(user.destroy()).to.be.rejected.then(() => { return expect(user.destroy()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce; expect(afterHook).to.have.been.calledOnce;
......
...@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
it('allow changing attributes via beforeFind #5675', function() { it('allow changing attributes via beforeFind #5675', function() {
this.User.beforeFind((options) => { this.User.beforeFind(options => {
options.attributes = { options.attributes = {
include: ['id'] include: ['id']
}; };
...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
afterHook = true; afterHook = true;
}); });
return this.User.find({where: {username: 'adam'}}).then((user) => { return this.User.find({where: {username: 'adam'}}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(beforeHook).to.be.true; expect(beforeHook).to.be.true;
expect(beforeHook2).to.be.true; expect(beforeHook2).to.be.true;
...@@ -71,41 +71,41 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -71,41 +71,41 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
it('beforeFind hook can change options', function() { it('beforeFind hook can change options', function() {
this.User.beforeFind((options) => { this.User.beforeFind(options => {
options.where.username = 'joe'; options.where.username = 'joe';
}); });
return this.User.find({where: {username: 'adam'}}).then((user) => { return this.User.find({where: {username: 'adam'}}).then(user => {
expect(user.mood).to.equal('sad'); expect(user.mood).to.equal('sad');
}); });
}); });
it('beforeFindAfterExpandIncludeAll hook can change options', function() { it('beforeFindAfterExpandIncludeAll hook can change options', function() {
this.User.beforeFindAfterExpandIncludeAll((options) => { this.User.beforeFindAfterExpandIncludeAll(options => {
options.where.username = 'joe'; options.where.username = 'joe';
}); });
return this.User.find({where: {username: 'adam'}}).then((user) => { return this.User.find({where: {username: 'adam'}}).then(user => {
expect(user.mood).to.equal('sad'); expect(user.mood).to.equal('sad');
}); });
}); });
it('beforeFindAfterOptions hook can change options', function() { it('beforeFindAfterOptions hook can change options', function() {
this.User.beforeFindAfterOptions((options) => { this.User.beforeFindAfterOptions(options => {
options.where.username = 'joe'; options.where.username = 'joe';
}); });
return this.User.find({where: {username: 'adam'}}).then((user) => { return this.User.find({where: {username: 'adam'}}).then(user => {
expect(user.mood).to.equal('sad'); expect(user.mood).to.equal('sad');
}); });
}); });
it('afterFind hook can change results', function() { it('afterFind hook can change results', function() {
this.User.afterFind((user) => { this.User.afterFind(user => {
user.mood = 'sad'; user.mood = 'sad';
}); });
return this.User.find({where: {username: 'adam'}}).then((user) => { return this.User.find({where: {username: 'adam'}}).then(user => {
expect(user.mood).to.equal('sad'); expect(user.mood).to.equal('sad');
}); });
}); });
...@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Oops!'); throw new Error('Oops!');
}); });
return this.User.find({where: {username: 'adam'}}).catch ((err) => { return this.User.find({where: {username: 'adam'}}).catch (err => {
expect(err.message).to.equal('Oops!'); expect(err.message).to.equal('Oops!');
}); });
}); });
...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Oops!'); throw new Error('Oops!');
}); });
return this.User.find({where: {username: 'adam'}}).catch ((err) => { return this.User.find({where: {username: 'adam'}}).catch (err => {
expect(err.message).to.equal('Oops!'); expect(err.message).to.equal('Oops!');
}); });
}); });
...@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Oops!'); throw new Error('Oops!');
}); });
return this.User.find({where: {username: 'adam'}}).catch ((err) => { return this.User.find({where: {username: 'adam'}}).catch (err => {
expect(err.message).to.equal('Oops!'); expect(err.message).to.equal('Oops!');
}); });
}); });
...@@ -147,7 +147,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -147,7 +147,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Oops!'); throw new Error('Oops!');
}); });
return this.User.find({where: {username: 'adam'}}).catch ((err) => { return this.User.find({where: {username: 'adam'}}).catch (err => {
expect(err.message).to.equal('Oops!'); expect(err.message).to.equal('Oops!');
}); });
}); });
......
...@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
attributes.type = DataTypes.STRING; attributes.type = DataTypes.STRING;
}); });
this.sequelize.addHook('afterDefine', (factory) => { this.sequelize.addHook('afterDefine', factory => {
factory.options.name.singular = 'barr'; factory.options.name.singular = 'barr';
}); });
...@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
options.host = 'server9'; options.host = 'server9';
}); });
Sequelize.addHook('afterInit', (sequelize) => { Sequelize.addHook('afterInit', sequelize => {
sequelize.options.protocol = 'udp'; sequelize.options.protocol = 'udp';
}); });
...@@ -186,7 +186,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -186,7 +186,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => { return User.create({ username: 'bob' }).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
expect(beforeHooked).to.be.true; expect(beforeHooked).to.be.true;
expect(afterHooked).to.be.true; expect(afterHooked).to.be.true;
...@@ -218,7 +218,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -218,7 +218,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => { return User.create({ username: 'bob' }).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
expect(beforeHooked).to.be.true; expect(beforeHooked).to.be.true;
expect(afterHooked).to.be.true; expect(afterHooked).to.be.true;
...@@ -250,7 +250,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -250,7 +250,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => { return User.create({ username: 'bob' }).then(user => {
user.username = 'bawb'; user.username = 'bawb';
return user.save({ fields: ['username'] }).then(() => { return user.save({ fields: ['username'] }).then(() => {
expect(beforeHooked).to.be.true; expect(beforeHooked).to.be.true;
...@@ -457,7 +457,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -457,7 +457,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.hook('beforeSave', sasukeHook); this.User.hook('beforeSave', sasukeHook);
this.User.hook('beforeSave', narutoHook); this.User.hook('beforeSave', narutoHook);
return this.User.create({ username: 'makunouchi'}).then((user) => { return this.User.create({ username: 'makunouchi'}).then(user => {
expect(sasukeHook).to.have.been.calledOnce; expect(sasukeHook).to.have.been.calledOnce;
expect(narutoHook).to.have.been.calledOnce; expect(narutoHook).to.have.been.calledOnce;
this.User.removeHook('beforeSave', sasukeHook); this.User.removeHook('beforeSave', sasukeHook);
......
...@@ -41,7 +41,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -41,7 +41,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.ParanoidUser.beforeRestore(beforeHook); this.ParanoidUser.beforeRestore(beforeHook);
this.ParanoidUser.afterRestore(afterHook); this.ParanoidUser.afterRestore(afterHook);
return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
return user.restore().then(() => { return user.restore().then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
...@@ -63,7 +63,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -63,7 +63,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
this.ParanoidUser.afterRestore(afterHook); this.ParanoidUser.afterRestore(afterHook);
return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
return expect(user.restore()).to.be.rejected.then(() => { return expect(user.restore()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
...@@ -83,7 +83,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -83,7 +83,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('Whoops!'); throw new Error('Whoops!');
}); });
return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.ParanoidUser.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.destroy().then(() => { return user.destroy().then(() => {
return expect(user.restore()).to.be.rejected.then(() => { return expect(user.restore()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
......
...@@ -34,8 +34,8 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -34,8 +34,8 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave); this.User.beforeSave(beforeSave);
this.User.afterSave(afterSave); this.User.afterSave(afterSave);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.updateAttributes({username: 'Chong'}).then((user) => { return user.updateAttributes({username: 'Chong'}).then(user => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce; expect(afterHook).to.have.been.calledOnce;
expect(beforeSave).to.have.been.calledTwice; expect(beforeSave).to.have.been.calledTwice;
...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave); this.User.beforeSave(beforeSave);
this.User.afterSave(afterSave); this.User.afterSave(afterSave);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return expect(user.updateAttributes({username: 'Chong'})).to.be.rejected.then(() => { return expect(user.updateAttributes({username: 'Chong'})).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(beforeSave).to.have.been.calledOnce; expect(beforeSave).to.have.been.calledOnce;
...@@ -85,7 +85,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -85,7 +85,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave); this.User.beforeSave(beforeSave);
this.User.afterSave(afterSave); this.User.afterSave(afterSave);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => { return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return expect(user.updateAttributes({username: 'Chong'})).to.be.rejected.then(() => { return expect(user.updateAttributes({username: 'Chong'})).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce; expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce; expect(afterHook).to.have.been.calledOnce;
...@@ -99,13 +99,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -99,13 +99,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('preserves changes to instance', () => { describe('preserves changes to instance', () => {
it('beforeValidate', function(){ it('beforeValidate', function(){
this.User.beforeValidate((user) => { this.User.beforeValidate(user => {
user.mood = 'happy'; user.mood = 'happy';
}); });
return this.User.create({username: 'fireninja', mood: 'invalid'}).then((user) => { return this.User.create({username: 'fireninja', mood: 'invalid'}).then(user => {
return user.updateAttributes({username: 'hero'}); return user.updateAttributes({username: 'hero'});
}).then((user) => { }).then(user => {
expect(user.username).to.equal('hero'); expect(user.username).to.equal('hero');
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
}); });
...@@ -113,13 +113,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -113,13 +113,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('afterValidate', function() { it('afterValidate', function() {
this.User.afterValidate((user) => { this.User.afterValidate(user => {
user.mood = 'sad'; user.mood = 'sad';
}); });
return this.User.create({username: 'fireninja', mood: 'nuetral'}).then((user) => { return this.User.create({username: 'fireninja', mood: 'nuetral'}).then(user => {
return user.updateAttributes({username: 'spider'}); return user.updateAttributes({username: 'spider'});
}).then((user) => { }).then(user => {
expect(user.username).to.equal('spider'); expect(user.username).to.equal('spider');
expect(user.mood).to.equal('sad'); expect(user.mood).to.equal('sad');
}); });
...@@ -128,14 +128,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -128,14 +128,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave', function() { it('beforeSave', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.beforeSave((user) => { this.User.beforeSave(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({username: 'fireninja', mood: 'nuetral'}).then((user) => { return this.User.create({username: 'fireninja', mood: 'nuetral'}).then(user => {
return user.updateAttributes({username: 'spider', mood: 'sad'}); return user.updateAttributes({username: 'spider', mood: 'sad'});
}).then((user) => { }).then(user => {
expect(user.username).to.equal('spider'); expect(user.username).to.equal('spider');
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(hookCalled).to.equal(2); expect(hookCalled).to.equal(2);
...@@ -145,19 +145,19 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -145,19 +145,19 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave with beforeUpdate', function() { it('beforeSave with beforeUpdate', function() {
let hookCalled = 0; let hookCalled = 0;
this.User.beforeUpdate((user) => { this.User.beforeUpdate(user => {
user.mood = 'sad'; user.mood = 'sad';
hookCalled++; hookCalled++;
}); });
this.User.beforeSave((user) => { this.User.beforeSave(user => {
user.mood = 'happy'; user.mood = 'happy';
hookCalled++; hookCalled++;
}); });
return this.User.create({username: 'akira'}).then((user) => { return this.User.create({username: 'akira'}).then(user => {
return user.updateAttributes({username: 'spider', mood: 'sad'}); return user.updateAttributes({username: 'spider', mood: 'sad'});
}).then((user) => { }).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('spider'); expect(user.username).to.equal('spider');
expect(hookCalled).to.equal(3); expect(hookCalled).to.equal(3);
......
...@@ -78,7 +78,7 @@ if (Support.sequelize.dialect.supports.upserts) { ...@@ -78,7 +78,7 @@ if (Support.sequelize.dialect.supports.upserts) {
let hookCalled = 0; let hookCalled = 0;
const valuesOriginal = { mood: 'sad', username: 'leafninja' }; const valuesOriginal = { mood: 'sad', username: 'leafninja' };
this.User.beforeUpsert((values) => { this.User.beforeUpsert(values => {
values.mood = 'happy'; values.mood = 'happy';
hookCalled++; hookCalled++;
}); });
......
...@@ -24,16 +24,16 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -24,16 +24,16 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('#validate', () => { describe('#validate', () => {
describe('#create', () => { describe('#create', () => {
it('should return the user', function() { it('should return the user', function() {
this.User.beforeValidate((user) => { this.User.beforeValidate(user => {
user.username = 'Bob'; user.username = 'Bob';
user.mood = 'happy'; user.mood = 'happy';
}); });
this.User.afterValidate((user) => { this.User.afterValidate(user => {
user.username = 'Toni'; user.username = 'Toni';
}); });
return this.User.create({mood: 'ecstatic'}).then((user) => { return this.User.create({mood: 'ecstatic'}).then(user => {
expect(user.mood).to.equal('happy'); expect(user.mood).to.equal('happy');
expect(user.username).to.equal('Toni'); expect(user.username).to.equal('Toni');
}); });
...@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('fields modified in hooks are saved', function() { it('fields modified in hooks are saved', function() {
const self = this; const self = this;
this.User.afterValidate((user) => { this.User.afterValidate(user => {
//if username is defined and has more than 5 char //if username is defined and has more than 5 char
user.username = user.username user.username = user.username
? user.username.length < 5 ? null : user.username ? user.username.length < 5 ? null : user.username
...@@ -53,12 +53,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -53,12 +53,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
}); });
this.User.beforeValidate((user) => { this.User.beforeValidate(user => {
user.mood = user.mood || 'neutral'; user.mood = user.mood || 'neutral';
}); });
return this.User.create({username: 'T', mood: 'neutral'}).then((user) => { return this.User.create({username: 'T', mood: 'neutral'}).then(user => {
expect(user.mood).to.equal('neutral'); expect(user.mood).to.equal('neutral');
expect(user.username).to.equal('Samorost 3'); expect(user.username).to.equal('Samorost 3');
...@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
user.username = 'Samorost Good One'; user.username = 'Samorost Good One';
return user.save(); return user.save();
}).then((uSaved) => { }).then(uSaved => {
expect(uSaved.mood).to.equal('sad'); expect(uSaved.mood).to.equal('sad');
expect(uSaved.username).to.equal('Samorost Good One'); expect(uSaved.username).to.equal('Samorost Good One');
...@@ -75,12 +75,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -75,12 +75,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uSaved.username = 'One'; uSaved.username = 'One';
return uSaved.save(); return uSaved.save();
}).then((uSaved) => { }).then(uSaved => {
//attributes were replaced by hooks ? //attributes were replaced by hooks ?
expect(uSaved.mood).to.equal('sad'); expect(uSaved.mood).to.equal('sad');
expect(uSaved.username).to.equal('Samorost 3'); expect(uSaved.username).to.equal('Samorost 3');
return self.User.findById(uSaved.id); return self.User.findById(uSaved.id);
}).then((uFetched) => { }).then(uFetched => {
expect(uFetched.mood).to.equal('sad'); expect(uFetched.mood).to.equal('sad');
expect(uFetched.username).to.equal('Samorost 3'); expect(uFetched.username).to.equal('Samorost 3');
...@@ -88,12 +88,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -88,12 +88,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uFetched.username = 'New Game is Needed'; uFetched.username = 'New Game is Needed';
return uFetched.save(); return uFetched.save();
}).then((uFetchedSaved) => { }).then(uFetchedSaved => {
expect(uFetchedSaved.mood).to.equal('neutral'); expect(uFetchedSaved.mood).to.equal('neutral');
expect(uFetchedSaved.username).to.equal('New Game is Needed'); expect(uFetchedSaved.username).to.equal('New Game is Needed');
return self.User.findById(uFetchedSaved.id); return self.User.findById(uFetchedSaved.id);
}).then((uFetched) => { }).then(uFetched => {
expect(uFetched.mood).to.equal('neutral'); expect(uFetched.mood).to.equal('neutral');
expect(uFetched.username).to.equal('New Game is Needed'); expect(uFetched.username).to.equal('New Game is Needed');
...@@ -101,7 +101,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -101,7 +101,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uFetched.username = 'New'; uFetched.username = 'New';
uFetched.mood = 'happy'; uFetched.mood = 'happy';
return uFetched.save(); return uFetched.save();
}).then((uFetchedSaved) => { }).then(uFetchedSaved => {
expect(uFetchedSaved.mood).to.equal('happy'); expect(uFetchedSaved.mood).to.equal('happy');
expect(uFetchedSaved.username).to.equal('Samorost 3'); expect(uFetchedSaved.username).to.equal('Samorost 3');
}); });
...@@ -110,7 +110,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -110,7 +110,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('on error', () => { describe('on error', () => {
it('should emit an error from after hook', function() { it('should emit an error from after hook', function() {
this.User.afterValidate((user) => { this.User.afterValidate(user => {
user.mood = 'ecstatic'; user.mood = 'ecstatic';
throw new Error('Whoops! Changed user.mood!'); throw new Error('Whoops! Changed user.mood!');
}); });
...@@ -133,7 +133,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -133,7 +133,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.validationFailed(validationFailedHook); this.User.validationFailed(validationFailedHook);
return expect(this.User.create({mood: 'happy'})).to.be.rejected.then((err) => { return expect(this.User.create({mood: 'happy'})).to.be.rejected.then(err => {
expect(err.name).to.equal('SequelizeValidationError'); expect(err.name).to.equal('SequelizeValidationError');
}); });
}); });
...@@ -143,7 +143,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { ...@@ -143,7 +143,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.validationFailed(validationFailedHook); this.User.validationFailed(validationFailedHook);
return expect(this.User.create({mood: 'happy'})).to.be.rejected.then((err) => { return expect(this.User.create({mood: 'happy'})).to.be.rejected.then(err => {
expect(err.message).to.equal('Whoops!'); expect(err.message).to.equal('Whoops!');
}); });
}); });
......
...@@ -26,7 +26,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -26,7 +26,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => { }).then(() => {
return User.find({ return User.find({
include: [{model: Company, as: 'Employer'}] include: [{model: Company, as: 'Employer'}]
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => { }).then(() => {
return User.findOne({ return User.findOne({
include: [Employer] include: [Employer]
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -56,7 +56,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -56,7 +56,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return Company.create({ return Company.create({
name: 'CyberCorp' name: 'CyberCorp'
}).then((company) => { }).then(company => {
return User.create({ return User.create({
employerId: company.get('id') employerId: company.get('id')
}); });
...@@ -66,7 +66,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -66,7 +66,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [ include: [
{association: Employer, where: {name: 'CyberCorp'}} {association: Employer, where: {name: 'CyberCorp'}}
] ]
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Company.create().then(() => { return Company.create().then(() => {
return Company.find({ return Company.find({
include: [{model: Person, as: 'CEO'}] include: [{model: Person, as: 'CEO'}]
}).then((company) => { }).then(company => {
expect(company).to.be.ok; expect(company).to.be.ok;
}); });
}); });
...@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Company.find({ return Company.find({
include: [CEO] include: [CEO]
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => { }).then(() => {
return Person.find({ return Person.find({
include: [Person.relation.Employer] include: [Person.relation.Employer]
}).then((person) => { }).then(person => {
expect(person).to.be.ok; expect(person).to.be.ok;
expect(person.employer).to.be.ok; expect(person.employer).to.be.ok;
}); });
...@@ -138,13 +138,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -138,13 +138,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User); Task.belongsTo(User);
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => { return User.create().then(user => {
return user.createTask(); return user.createTask();
}).then(() => { }).then(() => {
return User.find({ return User.find({
include: [Tasks] include: [Tasks]
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.tasks).to.be.ok; expect(user.tasks).to.be.ok;
}); });
...@@ -159,7 +159,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -159,7 +159,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User); Task.belongsTo(User);
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => { return User.create().then(user => {
return Promise.join( return Promise.join(
user.createTask({ user.createTask({
title: 'trivial' title: 'trivial'
...@@ -174,7 +174,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -174,7 +174,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{association: Tasks, where: {title: 'trivial'}} {association: Tasks, where: {title: 'trivial'}}
] ]
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.tasks).to.be.ok; expect(user.tasks).to.be.ok;
expect(user.tasks.length).to.equal(1); expect(user.tasks.length).to.equal(1);
...@@ -190,13 +190,13 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -190,13 +190,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Group.belongsToMany(User, { through: 'UserGroup' }); Group.belongsToMany(User, { through: 'UserGroup' });
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => { return User.create().then(user => {
return user.createGroup(); return user.createGroup();
}); });
}).then(() => { }).then(() => {
return User.find({ return User.find({
include: [Groups] include: [Groups]
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.groups).to.be.ok; expect(user.groups).to.be.ok;
}); });
...@@ -216,12 +216,12 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -216,12 +216,12 @@ describe(Support.getTestDialectTeaser('Include'), () => {
task: Task.create(), task: Task.create(),
user: User.create(), user: User.create(),
group: Group.create() group: Group.create()
}).then((props) => { }).then(props => {
return Promise.join( return Promise.join(
props.task.setUser(props.user), props.task.setUser(props.user),
props.user.setGroup(props.group) props.user.setGroup(props.group)
).return(props); ).return(props);
}).then((props) => { }).then(props => {
return Task.findOne({ return Task.findOne({
where: { where: {
id: props.task.id id: props.task.id
...@@ -231,7 +231,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -231,7 +231,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Group} {model: Group}
]} ]}
] ]
}).then((task) => { }).then(task => {
expect(task.User).to.be.ok; expect(task.User).to.be.ok;
expect(task.User.Group).to.be.ok; expect(task.User.Group).to.be.ok;
}); });
...@@ -254,7 +254,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -254,7 +254,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, { }, {
include: [User, Group] include: [User, Group]
}); });
}).then((task) => { }).then(task => {
return Task.find({ return Task.find({
where: { where: {
id: task.id id: task.id
...@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Group} {model: Group}
] ]
}); });
}).then((task) => { }).then(task => {
expect(task.User).to.be.ok; expect(task.User).to.be.ok;
expect(task.Group).to.be.ok; expect(task.Group).to.be.ok;
}); });
...@@ -286,7 +286,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -286,7 +286,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, { }, {
include: [Task, Group] include: [Task, Group]
}); });
}).then((user) => { }).then(user => {
return Group.find({ return Group.find({
where: { where: {
id: user.Group.id id: user.Group.id
...@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]} ]}
] ]
}); });
}).then((group) => { }).then(group => {
expect(group.User).to.be.ok; expect(group.User).to.be.ok;
expect(group.User.Task).to.be.ok; expect(group.User.Task).to.be.ok;
}); });
...@@ -324,7 +324,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -324,7 +324,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, { }, {
include: [Task] include: [Task]
}); });
}).then((user) => { }).then(user => {
return User.find({ return User.find({
where: { where: {
id: user.id id: user.id
...@@ -335,11 +335,11 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -335,11 +335,11 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]} ]}
] ]
}); });
}).then((user) => { }).then(user => {
expect(user.Tasks).to.be.ok; expect(user.Tasks).to.be.ok;
expect(user.Tasks.length).to.equal(4); expect(user.Tasks.length).to.equal(4);
user.Tasks.forEach((task) => { user.Tasks.forEach(task => {
expect(task.Project).to.be.ok; expect(task.Project).to.be.ok;
}); });
}); });
...@@ -361,7 +361,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -361,7 +361,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, { }, {
include: [Worker, Task] include: [Worker, Task]
}); });
}).then((project) => { }).then(project => {
return Worker.find({ return Worker.find({
where: { where: {
id: project.Workers[0].id id: project.Workers[0].id
...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]} ]}
] ]
}); });
}).then((worker) => { }).then(worker => {
expect(worker.Project).to.be.ok; expect(worker.Project).to.be.ok;
expect(worker.Project.Tasks).to.be.ok; expect(worker.Project.Tasks).to.be.ok;
expect(worker.Project.Tasks.length).to.equal(4); expect(worker.Project.Tasks.length).to.equal(4);
...@@ -436,7 +436,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -436,7 +436,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
[Product, 'id'] [Product, 'id']
] ]
}); });
}).then((user) => { }).then(user => {
expect(user.Products.length).to.equal(4); expect(user.Products.length).to.equal(4);
expect(user.Products[0].Tags.length).to.equal(2); expect(user.Products[0].Tags.length).to.equal(2);
expect(user.Products[1].Tags.length).to.equal(1); expect(user.Products[1].Tags.length).to.equal(1);
...@@ -541,7 +541,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -541,7 +541,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]} ]}
] ]
}); });
}).then((user) => { }).then(user => {
user.Memberships.sort(sortById); user.Memberships.sort(sortById);
expect(user.Memberships.length).to.equal(2); expect(user.Memberships.length).to.equal(2);
expect(user.Memberships[0].Group.name).to.equal('Developers'); expect(user.Memberships[0].Group.name).to.equal('Developers');
...@@ -588,7 +588,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -588,7 +588,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Project, attributes: ['title']} {model: Project, attributes: ['title']}
] ]
}); });
}).then((tasks) => { }).then(tasks => {
expect(tasks[0].title).to.equal('FooBar'); expect(tasks[0].title).to.equal('FooBar');
expect(tasks[0].Project.title).to.equal('BarFoo'); expect(tasks[0].Project.title).to.equal('BarFoo');
...@@ -608,7 +608,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -608,7 +608,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return Post.create({}); return Post.create({});
}).then((post) => { }).then(post => {
return post.createPostComment({ return post.createPostComment({
comment_title: 'WAT' comment_title: 'WAT'
}); });
...@@ -635,7 +635,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -635,7 +635,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
} }
] ]
}); });
}).then((posts) => { }).then(posts => {
expect(posts[0].PostComments[0].get('someProperty')).to.be.ok; expect(posts[0].PostComments[0].get('someProperty')).to.be.ok;
expect(posts[0].PostComments[0].get('someProperty2')).to.be.ok; expect(posts[0].PostComments[0].get('someProperty2')).to.be.ok;
expect(posts[0].PostComments[0].get('commentTitle')).to.equal('WAT'); expect(posts[0].PostComments[0].get('commentTitle')).to.equal('WAT');
...@@ -668,7 +668,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -668,7 +668,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, },
include: [{model: Group, as: 'OutsourcingCompanies'}] include: [{model: Group, as: 'OutsourcingCompanies'}]
}); });
}).then((group) => { }).then(group => {
expect(group.OutsourcingCompanies).to.have.length(3); expect(group.OutsourcingCompanies).to.have.length(3);
}); });
}); });
...@@ -699,7 +699,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -699,7 +699,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, },
include: [Group] include: [Group]
}); });
}).then((user) => { }).then(user => {
expect(user.dateField.getTime()).to.equal(Date.UTC(2014, 1, 20)); expect(user.dateField.getTime()).to.equal(Date.UTC(2014, 1, 20));
expect(user.groups[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20)); expect(user.groups[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20));
}); });
...@@ -747,7 +747,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -747,7 +747,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
as: 'Members' as: 'Members'
}] }]
}); });
}).then((groups) => { }).then(groups => {
expect(groups.length).to.equal(1); expect(groups.length).to.equal(1);
expect(groups[0].Members[0].name).to.equal('Member'); expect(groups[0].Members[0].name).to.equal('Member');
}); });
...@@ -796,7 +796,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -796,7 +796,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [ include: [
{model: this.Item, where: Sequelize.and({ test: 'def' })} {model: this.Item, where: Sequelize.and({ test: 'def' })}
] ]
}).then((result) => { }).then(result => {
expect(result.length).to.eql(1); expect(result.length).to.eql(1);
expect(result[0].Item.test).to.eql('def'); expect(result[0].Item.test).to.eql('def');
}); });
...@@ -825,7 +825,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -825,7 +825,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}} }}
] ]
}); });
}).then((result) => { }).then(result => {
expect(result.count).to.eql(1); expect(result.count).to.eql(1);
expect(result.rows.length).to.eql(1); expect(result.rows.length).to.eql(1);
...@@ -848,7 +848,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -848,7 +848,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({force: true}).then(() => { return this.sequelize.sync({force: true}).then(() => {
return Questionnaire.create(); return Questionnaire.create();
}).then((questionnaire) => { }).then(questionnaire => {
return questionnaire.getQuestions({ return questionnaire.getQuestions({
include: Answer include: Answer
}); });
...@@ -880,7 +880,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -880,7 +880,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Employee.create({ name: 'Jill' }), Employee.create({ name: 'Jill' }),
Clearence.create({ level: 3 }), Clearence.create({ level: 3 }),
Clearence.create({ level: 5 }) Clearence.create({ level: 5 })
]).then((instances) => { ]).then(instances => {
return Promise.all([ return Promise.all([
instances[0].addMembers([instances[2], instances[3]]), instances[0].addMembers([instances[2], instances[3]]),
instances[1].addMembers([instances[4], instances[5]]), instances[1].addMembers([instances[4], instances[5]]),
...@@ -905,7 +905,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -905,7 +905,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
} }
] ]
}).then((teams) => { }).then(teams => {
expect(teams).to.have.length(2); expect(teams).to.have.length(2);
}); });
}); });
...@@ -923,7 +923,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -923,7 +923,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
} }
] ]
}).then((teams) => { }).then(teams => {
expect(teams).to.have.length(2); expect(teams).to.have.length(2);
}); });
}); });
...@@ -942,7 +942,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -942,7 +942,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
} }
] ]
}).then((teams) => { }).then(teams => {
expect(teams).to.have.length(1); expect(teams).to.have.length(1);
}); });
}); });
......
...@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
force: true force: true
}).then(() => { }).then(() => {
return User.create(); return User.create();
}).then((user) => { }).then(user => {
return Task.bulkCreate([ return Task.bulkCreate([
{userId: user.get('id'), deletedAt: new Date()}, {userId: user.get('id'), deletedAt: new Date()},
{userId: user.get('id'), deletedAt: new Date()}, {userId: user.get('id'), deletedAt: new Date()},
...@@ -90,7 +90,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -90,7 +90,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Task, where: {deletedAt: null}, required: false} {model: Task, where: {deletedAt: null}, required: false}
] ]
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.Tasks.length).to.equal(0); expect(user.Tasks.length).to.equal(0);
}); });
...@@ -116,7 +116,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -116,7 +116,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
force: true force: true
}).then(() => { }).then(() => {
return User.create(); return User.create();
}).then((user) => { }).then(user => {
return Task.bulkCreate([ return Task.bulkCreate([
{userId: user.get('id'), searchString: 'one'}, {userId: user.get('id'), searchString: 'one'},
{userId: user.get('id'), searchString: 'two'} {userId: user.get('id'), searchString: 'two'}
...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Task, where: {searchString: 'one'} } {model: Task, where: {searchString: 'one'} }
] ]
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.Tasks.length).to.equal(1); expect(user.Tasks.length).to.equal(1);
}); });
...@@ -165,7 +165,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -165,7 +165,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
}); });
}) })
.then((a) => { .then(a => {
expect(a).to.not.equal(null); expect(a).to.not.equal(null);
expect(a.get('bs')).to.have.length(1); expect(a.get('bs')).to.have.length(1);
}); });
...@@ -198,7 +198,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -198,7 +198,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
}); });
}) })
.then((a) => { .then(a => {
expect(a).to.not.equal(null); expect(a).to.not.equal(null);
expect(a.get('bs')).to.deep.equal([]); expect(a.get('bs')).to.deep.equal([]);
}); });
...@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
}); });
}) })
.then((a) => { .then(a => {
expect(a).to.not.exist; expect(a).to.not.exist;
}); });
}); });
...@@ -252,14 +252,14 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -252,14 +252,14 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User, { foreignKey: 'user_name', targetKey: 'username'}); Task.belongsTo(User, { foreignKey: 'user_name', targetKey: 'username'});
return this.sequelize.sync({ force: true }).then(() => { return this.sequelize.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((newUser) => { return User.create({ username: 'bob' }).then(newUser => {
return Task.create({ title: 'some task' }).then((newTask) => { return Task.create({ title: 'some task' }).then(newTask => {
return newTask.setUser(newUser).then(() => { return newTask.setUser(newUser).then(() => {
return Task.find({ return Task.find({
where: { title: 'some task' }, where: { title: 'some task' },
include: [ { model: User } ] include: [ { model: User } ]
}) })
.then((foundTask) => { .then(foundTask => {
expect(foundTask).to.be.ok; expect(foundTask).to.be.ok;
expect(foundTask.User.username).to.equal('bob'); expect(foundTask.User.username).to.equal('bob');
}); });
...@@ -299,7 +299,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -299,7 +299,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
previousInstance, previousInstance,
b; b;
singles.forEach((model) => { singles.forEach(model => {
const values = {}; const values = {};
if (model.name === 'g') { if (model.name === 'g') {
...@@ -307,7 +307,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -307,7 +307,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
} }
promise = promise.then(() => { promise = promise.then(() => {
return model.create(values).then((instance) => { return model.create(values).then(instance => {
if (previousInstance) { if (previousInstance) {
return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => { return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => {
previousInstance = instance; previousInstance = instance;
...@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]} ]}
]} ]}
] ]
}).then((a) => { }).then(a => {
expect(a.b.c.d.e.f.g.h).to.be.ok; expect(a.b.c.d.e.f.g.h).to.be.ok;
}); });
}); });
......
...@@ -113,7 +113,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -113,7 +113,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
} }
}], }],
limit: 5 limit: 5
}).then((result ) => { }).then(result => {
expect(result.count).to.be.equal(2); expect(result.count).to.be.equal(2);
expect(result.rows.length).to.be.equal(2); expect(result.rows.length).to.be.equal(2);
}); });
...@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Project.sync({force: true}); return Project.sync({force: true});
}).then(() => { }).then(() => {
return Promise.all([User.create(), Project.create(), Project.create(), Project.create()]); return Promise.all([User.create(), Project.create(), Project.create(), Project.create()]);
}).then((results) => { }).then(results => {
const user = results[0]; const user = results[0];
userId = user.id; userId = user.id;
return user.setProjects([results[1], results[2], results[3]]); return user.setProjects([results[1], results[2], results[3]]);
...@@ -151,7 +151,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -151,7 +151,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [Project], include: [Project],
distinct: true distinct: true
}); });
}).then((result) => { }).then(result => {
expect(result.rows.length).to.equal(1); expect(result.rows.length).to.equal(1);
expect(result.rows[0].Projects.length).to.equal(3); expect(result.rows[0].Projects.length).to.equal(3);
expect(result.count).to.equal(1); expect(result.count).to.equal(1);
...@@ -181,11 +181,11 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -181,11 +181,11 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Foo.findAll({ return Foo.findAll({
include: [{ model: Bar, required: true }], include: [{ model: Bar, required: true }],
limit: 2 limit: 2
}).then((items) => { }).then(items => {
expect(items.length).to.equal(2); expect(items.length).to.equal(2);
}); });
}); });
}).then((result) => { }).then(result => {
expect(result.count).to.equal(4); expect(result.count).to.equal(4);
// The first two of those should be returned due to the limit (Foo // The first two of those should be returned due to the limit (Foo
...@@ -213,7 +213,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -213,7 +213,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
limit: 1, limit: 1,
distinct: true distinct: true
}); });
}).then((result) => { }).then(result => {
// There should be 2 instances matching the query (Instances 1 and 2), see the findAll statement // There should be 2 instances matching the query (Instances 1 and 2), see the findAll statement
expect(result.count).to.equal(2); expect(result.count).to.equal(2);
...@@ -289,7 +289,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -289,7 +289,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
] ]
}); });
}); });
}).then((result) => { }).then(result => {
expect(result.count).to.equal(2); expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(1); expect(result.rows.length).to.equal(1);
}); });
...@@ -340,7 +340,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { ...@@ -340,7 +340,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
} }
] ]
}); });
}).then((result) => { }).then(result => {
expect(result.count).to.equal(2); expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(1); expect(result.rows.length).to.equal(1);
}); });
......
...@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => { ...@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
return X.findAll({ return X.findAll({
include: [Y] include: [Y]
}).get(0); }).get(0);
}).then((x) => { }).then(x => {
expect(x.ys).to.have.length(0); expect(x.ys).to.have.length(0);
}); });
}); });
......
...@@ -120,7 +120,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -120,7 +120,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Tag.findAll() Tag.findAll()
]); ]);
}).spread((groups, companies, ranks, tags) => { }).spread((groups, companies, ranks, tags) => {
return Promise.each([0, 1, 2, 3, 4], (i) => { return Promise.each([0, 1, 2, 3, 4], i => {
return Promise.all([ return Promise.all([
AccUser.create(), AccUser.create(),
Product.bulkCreate([ Product.bulkCreate([
...@@ -262,7 +262,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -262,7 +262,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
return Tag.findAll(); return Tag.findAll();
}) })
]).spread((groups, ranks, tags) => { ]).spread((groups, ranks, tags) => {
return Promise.each([0, 1, 2, 3, 4], (i) => { return Promise.each([0, 1, 2, 3, 4], i => {
return Promise.all([ return Promise.all([
AccUser.create(), AccUser.create(),
Product.bulkCreate([ Product.bulkCreate([
...@@ -316,8 +316,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -316,8 +316,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [ order: [
[AccUser.rawAttributes.id, 'ASC'] [AccUser.rawAttributes.id, 'ASC']
] ]
}).then((users) => { }).then(users => {
users.forEach((user) => { users.forEach(user => {
expect(user.Memberships).to.be.ok; expect(user.Memberships).to.be.ok;
user.Memberships.sort(sortById); user.Memberships.sort(sortById);
...@@ -378,8 +378,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -378,8 +378,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
{}, {}, {}, {}, {}, {}, {}, {} {}, {}, {}, {}, {}, {}, {}, {}
]).then(() => { ]).then(() => {
let previousInstance; let previousInstance;
return Promise.each(singles, (model) => { return Promise.each(singles, model => {
return model.create({}).then((instance) => { return model.create({}).then(instance => {
if (previousInstance) { if (previousInstance) {
return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => { return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => {
previousInstance = instance; previousInstance = instance;
...@@ -391,9 +391,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -391,9 +391,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
}); });
}).then(() => { }).then(() => {
return A.findAll(); return A.findAll();
}).then((as) => { }).then(as => {
const promises = []; const promises = [];
as.forEach((a) => { as.forEach(a => {
promises.push(a.setB(b)); promises.push(a.setB(b));
}); });
return Promise.all(promises); return Promise.all(promises);
...@@ -414,9 +414,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -414,9 +414,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]} ]}
]} ]}
] ]
}).then((as) => { }).then(as => {
expect(as.length).to.be.ok; expect(as.length).to.be.ok;
as.forEach((a) => { as.forEach(a => {
expect(a.b.c.d.e.f.g.h).to.be.ok; expect(a.b.c.d.e.f.g.h).to.be.ok;
}); });
}); });
...@@ -474,7 +474,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -474,7 +474,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
'order': [ 'order': [
[Order, 'position'] [Order, 'position']
] ]
}).then((as) => { }).then(as => {
expect(as.length).to.eql(2); expect(as.length).to.eql(2);
expect(as[0].itemA.test).to.eql('abc'); expect(as[0].itemA.test).to.eql('abc');
expect(as[1].itemA.test).to.eql('abc'); expect(as[1].itemA.test).to.eql('abc');
...@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
['id', 'ASC'], ['id', 'ASC'],
[Tag, 'id', 'ASC'] [Tag, 'id', 'ASC']
] ]
}).then((products) => { }).then(products => {
expect(products[0].Tags[0].ProductTag.priority).to.equal(1); expect(products[0].Tags[0].ProductTag.priority).to.equal(1);
expect(products[0].Tags[1].ProductTag.priority).to.equal(2); expect(products[0].Tags[1].ProductTag.priority).to.equal(2);
expect(products[1].Tags[0].ProductTag.priority).to.equal(1); expect(products[1].Tags[0].ProductTag.priority).to.equal(1);
...@@ -568,7 +568,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -568,7 +568,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [ include: [
{model: Group, required: true} {model: Group, required: true}
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
expect(users[0].Group).to.be.ok; expect(users[0].Group).to.be.ok;
}); });
...@@ -606,7 +606,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -606,7 +606,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [ include: [
{model: Group, where: {name: 'A'}} {model: Group, where: {name: 'A'}}
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
expect(users[0].Group).to.be.ok; expect(users[0].Group).to.be.ok;
expect(users[0].Group.name).to.equal('A'); expect(users[0].Group.name).to.equal('A');
...@@ -645,8 +645,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -645,8 +645,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [ include: [
{model: Group, required: true} {model: Group, required: true}
] ]
}).then((users) => { }).then(users => {
users.forEach((user) => { users.forEach(user => {
expect(user.Group).to.be.ok; expect(user.Group).to.be.ok;
}); });
}); });
...@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setGroup(groups[1]), users[0].setGroup(groups[1]),
users[1].setGroup(groups[0]) users[1].setGroup(groups[0])
]; ];
groups.forEach((group) => { groups.forEach(group => {
promises.push(group.setCategories(categories)); promises.push(group.setCategories(categories));
}); });
return Promise.all(promises); return Promise.all(promises);
...@@ -697,9 +697,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -697,9 +697,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]} ]}
], ],
limit: 1 limit: 1
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.Group).to.be.ok; expect(user.Group).to.be.ok;
expect(user.Group.Categories).to.be.ok; expect(user.Group.Categories).to.be.ok;
}); });
...@@ -739,7 +739,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -739,7 +739,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setTeam(groups[1]), users[0].setTeam(groups[1]),
users[1].setTeam(groups[0]) users[1].setTeam(groups[0])
]; ];
groups.forEach((group) => { groups.forEach(group => {
promises.push(group.setTags(categories)); promises.push(group.setTags(categories));
}); });
return Promise.all(promises); return Promise.all(promises);
...@@ -751,9 +751,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -751,9 +751,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]} ]}
], ],
limit: 1 limit: 1
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.Team).to.be.ok; expect(user.Team).to.be.ok;
expect(user.Team.Tags).to.be.ok; expect(user.Team.Tags).to.be.ok;
}); });
...@@ -793,7 +793,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -793,7 +793,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setGroup(groups[1]), users[0].setGroup(groups[1]),
users[1].setGroup(groups[0]) users[1].setGroup(groups[0])
]; ];
groups.forEach((group) => { groups.forEach(group => {
promises.push(group.setCategories(categories)); promises.push(group.setCategories(categories));
}); });
return Promise.all(promises); return Promise.all(promises);
...@@ -805,9 +805,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -805,9 +805,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]} ]}
], ],
limit: 1 limit: 1
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.Group).to.be.ok; expect(user.Group).to.be.ok;
expect(user.Group.Categories).to.be.ok; expect(user.Group.Categories).to.be.ok;
}); });
...@@ -846,7 +846,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -846,7 +846,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [ include: [
{model: Project, as: 'LeaderOf', where: {title: 'Beta'}} {model: Project, as: 'LeaderOf', where: {title: 'Beta'}}
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
expect(users[0].LeaderOf).to.be.ok; expect(users[0].LeaderOf).to.be.ok;
expect(users[0].LeaderOf.title).to.equal('Beta'); expect(users[0].LeaderOf.title).to.equal('Beta');
...@@ -900,7 +900,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -900,7 +900,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [ include: [
{model: Tag, where: {name: 'C'}} {model: Tag, where: {name: 'C'}}
] ]
}).then((products) => { }).then(products => {
expect(products.length).to.equal(1); expect(products.length).to.equal(1);
expect(products[0].Tags.length).to.equal(1); expect(products[0].Tags.length).to.equal(1);
}); });
...@@ -977,7 +977,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -977,7 +977,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Tag.findAll() Tag.findAll()
]); ]);
}).spread((groups, ranks, tags) => { }).spread((groups, ranks, tags) => {
return Promise.resolve([0, 1, 2, 3, 4]).each((i) => { return Promise.resolve([0, 1, 2, 3, 4]).each(i => {
return Promise.all([ return Promise.all([
User.create({name: 'FooBarzz'}), User.create({name: 'FooBarzz'}),
Product.bulkCreate([ Product.bulkCreate([
...@@ -1035,8 +1035,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1035,8 +1035,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}).then((users) => { }).then(users => {
users.forEach((user) => { users.forEach(user => {
expect(user.Memberships.length).to.equal(1); expect(user.Memberships.length).to.equal(1);
expect(user.Memberships[0].Rank.name).to.equal('Admin'); expect(user.Memberships[0].Rank.name).to.equal('Admin');
expect(user.Products.length).to.equal(1); expect(user.Products.length).to.equal(1);
...@@ -1066,7 +1066,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1066,7 +1066,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users: User.bulkCreate([{}, {}, {}, {}]).then(() => { users: User.bulkCreate([{}, {}, {}, {}]).then(() => {
return User.findAll(); return User.findAll();
}) })
}).then((results) => { }).then(results => {
return Promise.join( return Promise.join(
results.users[1].setGroup(results.groups[0]), results.users[1].setGroup(results.groups[0]),
results.users[2].setGroup(results.groups[0]), results.users[2].setGroup(results.groups[0]),
...@@ -1079,10 +1079,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1079,10 +1079,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
{model: Group, where: {name: 'A'}} {model: Group, where: {name: 'A'}}
], ],
limit: 2 limit: 2
}).then((users) => { }).then(users => {
expect(users.length).to.equal(2); expect(users.length).to.equal(2);
users.forEach((user) => { users.forEach(user => {
expect(user.Group.name).to.equal('A'); expect(user.Group.name).to.equal('A');
}); });
}); });
...@@ -1104,10 +1104,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1104,10 +1104,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}).then((products) => { }).then(products => {
expect(products.length).to.equal(3); expect(products.length).to.equal(3);
products.forEach((product) => { products.forEach(product => {
expect(product.Company.name).to.equal('NYSE'); expect(product.Company.name).to.equal('NYSE');
expect(product.Tags.length).to.be.ok; expect(product.Tags.length).to.be.ok;
expect(product.Prices.length).to.be.ok; expect(product.Prices.length).to.be.ok;
...@@ -1131,14 +1131,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1131,14 +1131,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}).then((products) => { }).then(products => {
expect(products.length).to.equal(6); expect(products.length).to.equal(6);
products.forEach((product) => { products.forEach(product => {
expect(product.Tags.length).to.be.ok; expect(product.Tags.length).to.be.ok;
expect(product.Prices.length).to.be.ok; expect(product.Prices.length).to.be.ok;
product.Prices.forEach((price) => { product.Prices.forEach(price => {
expect(price.value).to.be.above(5); expect(price.value).to.be.above(5);
}); });
}); });
...@@ -1159,14 +1159,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1159,14 +1159,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}).then((products) => { }).then(products => {
expect(products.length).to.equal(10); expect(products.length).to.equal(10);
products.forEach((product) => { products.forEach(product => {
expect(product.Tags.length).to.be.ok; expect(product.Tags.length).to.be.ok;
expect(product.Prices.length).to.be.ok; expect(product.Prices.length).to.be.ok;
product.Tags.forEach((tag) => { product.Tags.forEach(tag => {
expect(['A', 'B', 'C']).to.include(tag.name); expect(['A', 'B', 'C']).to.include(tag.name);
}); });
}); });
...@@ -1186,15 +1186,15 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { ...@@ -1186,15 +1186,15 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Group.belongsToMany(User, {through: 'group_user'}); Group.belongsToMany(User, {through: 'group_user'});
return this.sequelize.sync().then(() => { return this.sequelize.sync().then(() => {
return User.create({ dateField: Date.UTC(2014, 1, 20) }).then((user) => { return User.create({ dateField: Date.UTC(2014, 1, 20) }).then(user => {
return Group.create({ dateField: Date.UTC(2014, 1, 20) }).then((group) => { return Group.create({ dateField: Date.UTC(2014, 1, 20) }).then(group => {
return user.addGroup(group).then(() => { return user.addGroup(group).then(() => {
return User.findAll({ return User.findAll({
where: { where: {
id: user.id id: user.id
}, },
include: [Group] include: [Group]
}).then((users) => { }).then(users => {
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
expect(new Date(users[0].dateField).getTime()).to.equal(Date.UTC(2014, 1, 20)); expect(new Date(users[0].dateField).getTime()).to.equal(Date.UTC(2014, 1, 20));
expect(new Date(users[0].groups[0].dateField).getTime()).to.equal(Date.UTC(2014, 1, 20)); expect(new Date(users[0].groups[0].dateField).getTime()).to.equal(Date.UTC(2014, 1, 20));
......
...@@ -50,7 +50,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -50,7 +50,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((users) => { }).then(users => {
expect(users[0].get('tasks')).to.be.ok; expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(3); expect(users[0].get('tasks').length).to.equal(3);
expect(users[1].get('tasks')).to.be.ok; expect(users[1].get('tasks')).to.be.ok;
...@@ -94,7 +94,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -94,7 +94,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((users) => { }).then(users => {
expect(users[0].get('tasks')).to.be.ok; expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(3); expect(users[0].get('tasks').length).to.equal(3);
expect(sqlSpy).to.have.been.calledTwice; expect(sqlSpy).to.have.been.calledTwice;
...@@ -166,7 +166,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -166,7 +166,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((users) => { }).then(users => {
expect(users[0].get('tasks')).to.be.ok; expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(2); expect(users[0].get('tasks').length).to.equal(2);
expect(users[1].get('tasks')).to.be.ok; expect(users[1].get('tasks')).to.be.ok;
...@@ -225,7 +225,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -225,7 +225,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((users) => { }).then(users => {
expect(users[0].get('company').get('tasks')).to.be.ok; expect(users[0].get('company').get('tasks')).to.be.ok;
expect(users[0].get('company').get('tasks').length).to.equal(3); expect(users[0].get('company').get('tasks').length).to.equal(3);
expect(users[1].get('company').get('tasks')).to.be.ok; expect(users[1].get('company').get('tasks')).to.be.ok;
...@@ -282,7 +282,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -282,7 +282,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((companies) => { }).then(companies => {
expect(sqlSpy).to.have.been.calledTwice; expect(sqlSpy).to.have.been.calledTwice;
expect(companies[0].users[0].tasks[0].project).to.be.ok; expect(companies[0].users[0].tasks[0].project).to.be.ok;
...@@ -352,7 +352,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -352,7 +352,7 @@ if (current.dialect.supports.groupedLimit) {
], ],
logging: sqlSpy logging: sqlSpy
}); });
}).then((users) => { }).then(users => {
const u1projects = users[0].get('projects'); const u1projects = users[0].get('projects');
expect(u1projects).to.be.ok; expect(u1projects).to.be.ok;
...@@ -361,8 +361,8 @@ if (current.dialect.supports.groupedLimit) { ...@@ -361,8 +361,8 @@ if (current.dialect.supports.groupedLimit) {
expect(u1projects.length).to.equal(2); expect(u1projects.length).to.equal(2);
// WTB ES2015 syntax ... // WTB ES2015 syntax ...
expect(_.find(u1projects, (p) => { return p.id === 1; }).get('tasks').length).to.equal(3); expect(_.find(u1projects, p => { return p.id === 1; }).get('tasks').length).to.equal(3);
expect(_.find(u1projects, (p) => { return p.id === 2; }).get('tasks').length).to.equal(1); expect(_.find(u1projects, p => { return p.id === 2; }).get('tasks').length).to.equal(1);
expect(users[1].get('projects')).to.be.ok; expect(users[1].get('projects')).to.be.ok;
expect(users[1].get('projects')[0].get('tasks')).to.be.ok; expect(users[1].get('projects')[0].get('tasks')).to.be.ok;
...@@ -415,7 +415,7 @@ if (current.dialect.supports.groupedLimit) { ...@@ -415,7 +415,7 @@ if (current.dialect.supports.groupedLimit) {
order: [ order: [
['id', 'ASC'] ['id', 'ASC']
] ]
}).then((result) => { }).then(result => {
expect(result[0].tasks.length).to.equal(2); expect(result[0].tasks.length).to.equal(2);
expect(result[0].tasks[0].title).to.equal('b'); expect(result[0].tasks[0].title).to.equal('b');
expect(result[0].tasks[1].title).to.equal('d'); expect(result[0].tasks[1].title).to.equal('d');
......
...@@ -23,11 +23,11 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -23,11 +23,11 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob', email: 'hello@world.com' }).then((user) => { return User.create({ username: 'bob', email: 'hello@world.com' }).then(user => {
return User return User
.update({ username: 'toni' }, { where: {id: user.id }}) .update({ username: 'toni' }, { where: {id: user.id }})
.then(() => { .then(() => {
return User.findById(1).then((user) => { return User.findById(1).then(user => {
expect(user.username).to.equal('toni'); expect(user.username).to.equal('toni');
}); });
}); });
...@@ -47,8 +47,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -47,8 +47,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return Model.sync({ force: true }).then(() => { return Model.sync({ force: true }).then(() => {
return Model.create({name: 'World'}).then((model) => { return Model.create({name: 'World'}).then(model => {
return model.updateAttributes({name: ''}).catch((err) => { return model.updateAttributes({name: ''}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('name')[0].message).to.equal('Validation notEmpty on name failed'); expect(err.get('name')[0].message).to.equal('Validation notEmpty on name failed');
}); });
...@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true }).then(() => { return Model.sync({ force: true }).then(() => {
return Model.create({name: 'World'}).then(() => { return Model.create({name: 'World'}).then(() => {
return Model.update({name: ''}, {where: {id: 1}}).catch((err) => { return Model.update({name: ''}, {where: {id: 1}}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('name')[0].message).to.equal('Validation notEmpty on name failed'); expect(err.get('name')[0].message).to.equal('Validation notEmpty on name failed');
}); });
...@@ -88,13 +88,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -88,13 +88,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true }) return Model.sync({ force: true })
.then(() => { .then(() => {
return Model.create(records[0]); return Model.create(records[0]);
}).then((instance) => { }).then(instance => {
expect(instance).to.be.ok; expect(instance).to.be.ok;
return Model.create(records[1]); return Model.create(records[1]);
}).then((instance) => { }).then(instance => {
expect(instance).to.be.ok; expect(instance).to.be.ok;
return expect(Model.update(records[0], { where: { id: instance.id } })).to.be.rejected; return expect(Model.update(records[0], { where: { id: instance.id } })).to.be.rejected;
}).then((err) => { }).then(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1); expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName'); expect(err.errors[0].path).to.include('uniqueName');
...@@ -116,13 +116,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -116,13 +116,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true }) return Model.sync({ force: true })
.then(() => { .then(() => {
return Model.create(records[0]); return Model.create(records[0]);
}).then((instance) => { }).then(instance => {
expect(instance).to.be.ok; expect(instance).to.be.ok;
return Model.create(records[1]); return Model.create(records[1]);
}).then((instance) => { }).then(instance => {
expect(instance).to.be.ok; expect(instance).to.be.ok;
return expect(Model.update(records[0], { where: { id: instance.id } })).to.be.rejected; return expect(Model.update(records[0], { where: { id: instance.id } })).to.be.rejected;
}).then((err) => { }).then(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1); expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName'); expect(err.errors[0].path).to.include('uniqueName');
...@@ -149,17 +149,17 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -149,17 +149,17 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true }) return Model.sync({ force: true })
.then(() => { .then(() => {
return Model.create(records[0]); return Model.create(records[0]);
}).then((instance) => { }).then(instance => {
expect(instance).to.be.ok; expect(instance).to.be.ok;
return expect(Model.create(records[1])).to.be.rejected; return expect(Model.create(records[1])).to.be.rejected;
}).then((err) => { }).then(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1); expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName1'); expect(err.errors[0].path).to.include('uniqueName1');
expect(err.errors[0].message).to.equal('custom unique error message 1'); expect(err.errors[0].message).to.equal('custom unique error message 1');
return expect(Model.create(records[2])).to.be.rejected; return expect(Model.create(records[2])).to.be.rejected;
}).then((err) => { }).then(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1); expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName2'); expect(err.errors[0].path).to.include('uniqueName2');
...@@ -198,18 +198,18 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -198,18 +198,18 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
it('correctly throws an error using create method ', function() { it('correctly throws an error using create method ', function() {
return this.Project.create({name: 'nope'}).catch((err) => { return this.Project.create({name: 'nope'}).catch(err => {
expect(err).to.have.ownProperty('name'); expect(err).to.have.ownProperty('name');
}); });
}); });
it('correctly validates using create method ', function() { it('correctly validates using create method ', function() {
const self = this; const self = this;
return this.Project.create({}).then((project) => { return this.Project.create({}).then(project => {
return self.Task.create({something: 1}).then((task) => { return self.Task.create({something: 1}).then(task => {
return project.setTask(task).then((task) => { return project.setTask(task).then(task => {
expect(task.ProjectId).to.not.be.null; expect(task.ProjectId).to.not.be.null;
return task.setProject(project).then((project) => { return task.setProject(project).then(project => {
expect(project.ProjectId).to.not.be.null; expect(project.ProjectId).to.not.be.null;
}); });
}); });
...@@ -232,7 +232,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -232,7 +232,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({id: 'helloworld'}).catch((err) => { return User.create({id: 'helloworld'}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('id')[0].message).to.equal('Validation isInt on id failed'); expect(err.get('id')[0].message).to.equal('Validation isInt on id failed');
}); });
...@@ -252,7 +252,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -252,7 +252,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({username: 'helloworldhelloworld'}).catch((err) => { return User.create({username: 'helloworldhelloworld'}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('username')[0].message).to.equal('Username must be an integer!'); expect(err.get('username')[0].message).to.equal('Username must be an integer!');
}); });
...@@ -276,7 +276,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -276,7 +276,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
it('should emit an error when we try to enter in a string for the id key with validation arguments', function() { it('should emit an error when we try to enter in a string for the id key with validation arguments', function() {
return this.User.create({id: 'helloworld'}).catch((err) => { return this.User.create({id: 'helloworld'}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('id')[0].message).to.equal('ID must be an integer!'); expect(err.get('id')[0].message).to.equal('ID must be an integer!');
}); });
...@@ -285,14 +285,14 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -285,14 +285,14 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
it('should emit an error when we try to enter in a string for an auto increment key through .build().validate()', function() { it('should emit an error when we try to enter in a string for an auto increment key through .build().validate()', function() {
const user = this.User.build({id: 'helloworld'}); const user = this.User.build({id: 'helloworld'});
return expect(user.validate()).to.be.rejected.then((err) => { return expect(user.validate()).to.be.rejected.then(err => {
expect(err.get('id')[0].message).to.equal('ID must be an integer!'); expect(err.get('id')[0].message).to.equal('ID must be an integer!');
}); });
}); });
it('should emit an error when we try to .save()', function() { it('should emit an error when we try to .save()', function() {
const user = this.User.build({id: 'helloworld'}); const user = this.User.build({id: 'helloworld'});
return user.save().catch((err) => { return user.save().catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
expect(err.get('id')[0].message).to.equal('ID must be an integer!'); expect(err.get('id')[0].message).to.equal('ID must be an integer!');
}); });
...@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
it('produce 3 errors', function() { it('produce 3 errors', function() {
return this.Project.create({}).catch((err) => { return this.Project.create({}).catch(err => {
expect(err).to.be.an.instanceOf(Error); expect(err).to.be.an.instanceOf(Error);
delete err.stack; // longStackTraces delete err.stack; // longStackTraces
expect(err.errors).to.have.length(3); expect(err.errors).to.have.length(3);
...@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
const failingUser = User.build({ name: '3' }); const failingUser = User.build({ name: '3' });
return expect(failingUser.validate()).to.be.rejected.then((error) => { return expect(failingUser.validate()).to.be.rejected.then(error => {
expect(error).to.be.an.instanceOf(Error); expect(error).to.be.an.instanceOf(Error);
expect(error.get('name')[0].message).to.equal("name should equal '2'"); expect(error.get('name')[0].message).to.equal("name should equal '2'");
...@@ -392,7 +392,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -392,7 +392,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return User.sync().then(() => { return User.sync().then(() => {
return expect(User.build({ name: 'error' }).validate()).to.be.rejected.then((error) => { return expect(User.build({ name: 'error' }).validate()).to.be.rejected.then(error => {
expect(error).to.be.instanceof(self.sequelize.ValidationError); expect(error).to.be.instanceof(self.sequelize.ValidationError);
expect(error.get('name')[0].message).to.equal('Invalid username'); expect(error.get('name')[0].message).to.equal('Invalid username');
...@@ -416,7 +416,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -416,7 +416,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
.build({ age: -1 }) .build({ age: -1 })
.validate()) .validate())
.to.be.rejected .to.be.rejected
.then((error) => { .then(error => {
expect(error.get('age')[0].message).to.equal('must be positive'); expect(error.get('age')[0].message).to.equal('must be positive');
}); });
}); });
...@@ -445,7 +445,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -445,7 +445,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
.build({ field1: null, field2: null }) .build({ field1: null, field2: null })
.validate()) .validate())
.to.be.rejected .to.be.rejected
.then((error) => { .then(error => {
expect(error.get('xnor')[0].message).to.equal('xnor failed'); expect(error.get('xnor')[0].message).to.equal('xnor failed');
return expect(Foo return expect(Foo
...@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
const failingBar = Bar.build({ field: 'value3' }); const failingBar = Bar.build({ field: 'value3' });
return expect(failingBar.validate()).to.be.rejected.then((errors) => { return expect(failingBar.validate()).to.be.rejected.then(errors => {
expect(errors.get('field')).to.have.length(1); expect(errors.get('field')).to.have.length(1);
expect(errors.get('field')[0].message).to.equal('Validation isIn on field failed'); expect(errors.get('field')[0].message).to.equal('Validation isIn on field failed');
}); });
...@@ -520,10 +520,10 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -520,10 +520,10 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
return User.sync({force: true}).then(() => { return User.sync({force: true}).then(() => {
return User.create({ name: 'RedCat' }).then((user) => { return User.create({ name: 'RedCat' }).then(user => {
expect(user.getDataValue('name')).to.equal('RedCat'); expect(user.getDataValue('name')).to.equal('RedCat');
user.setDataValue('name', 'YellowCat'); user.setDataValue('name', 'YellowCat');
return expect(user.save()).to.be.rejected.then((errors) => { return expect(user.save()).to.be.rejected.then(errors => {
expect(errors.get('name')[0].message).to.eql('Validation isImmutable on name failed'); expect(errors.get('name')[0].message).to.eql('Validation isImmutable on name failed');
}); });
}); });
...@@ -655,7 +655,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -655,7 +655,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
expect(User.build({ expect(User.build({
password: 'short', password: 'short',
salt: '42' salt: '42'
}).validate()).to.be.rejected.then((errors) => { }).validate()).to.be.rejected.then(errors => {
expect(errors.get('password')[0].message).to.equal('Please choose a longer password'); expect(errors.get('password')[0].message).to.equal('Please choose a longer password');
}), }),
expect(User.build({ expect(User.build({
...@@ -666,7 +666,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -666,7 +666,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
}); });
it('allows me to add custom validation functions to validator.js', function() { it('allows me to add custom validation functions to validator.js', function() {
this.sequelize.Validator.extend('isExactly7Characters', (val) => { this.sequelize.Validator.extend('isExactly7Characters', val => {
return val.length === 7; return val.length === 7;
}); });
...@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => { ...@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return expect(User.build({ return expect(User.build({
name: 'a' name: 'a'
}).validate()).to.be.rejected; }).validate()).to.be.rejected;
}).then((errors) => { }).then(errors => {
expect(errors.get('name')[0].message).to.equal('Validation isExactly7Characters on name failed'); expect(errors.get('name')[0].message).to.equal('Validation isExactly7Characters on name failed');
}); });
}); });
......
...@@ -64,15 +64,15 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -64,15 +64,15 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
if (current.dialect.supports.transactions) { if (current.dialect.supports.transactions) {
it('supports transactions', function() { it('supports transactions', function() {
return Support.prepareTransactionTest(this.sequelize).bind({}).then((sequelize) => { return Support.prepareTransactionTest(this.sequelize).bind({}).then(sequelize => {
const User = sequelize.define('User', { username: Support.Sequelize.STRING }); const User = sequelize.define('User', { username: Support.Sequelize.STRING });
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({ username: 'foo' }).then((user) => { return User.create({ username: 'foo' }).then(user => {
return sequelize.transaction().then((t) => { return sequelize.transaction().then(t => {
return user.update({ username: 'bar' }, { transaction: t }).then(() => { return user.update({ username: 'bar' }, { transaction: t }).then(() => {
return User.findAll().then((users1) => { return User.findAll().then(users1 => {
return User.findAll({ transaction: t }).then((users2) => { return User.findAll({ transaction: t }).then(users2 => {
expect(users1[0].username).to.equal('foo'); expect(users1[0].username).to.equal('foo');
expect(users2[0].username).to.equal('bar'); expect(users2[0].username).to.equal('bar');
return t.rollback(); return t.rollback();
...@@ -99,11 +99,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -99,11 +99,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: 'email' email: 'email'
}, { }, {
fields: ['name', 'email'] fields: ['name', 'email']
}).then((user) => { }).then(user => {
return user.update({bio: 'swag'}); return user.update({bio: 'swag'});
}).then((user) => { }).then(user => {
return user.reload(); return user.reload();
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('snafu'); expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email'); expect(user.get('email')).to.equal('email');
expect(user.get('bio')).to.equal('swag'); expect(user.get('bio')).to.equal('swag');
...@@ -126,14 +126,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -126,14 +126,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: 'email' email: 'email'
}, { }, {
fields: ['name', 'email'] fields: ['name', 'email']
}).then((user) => { }).then(user => {
return user.update({ return user.update({
name: 'snafu', name: 'snafu',
email: 'email' email: 'email'
}); });
}).then((user) => { }).then(user => {
return user.reload(); return user.reload();
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('snafu'); expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email'); expect(user.get('email')).to.equal('email');
}); });
...@@ -158,9 +158,9 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -158,9 +158,9 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return User.create({ return User.create({
name: 'snafu', name: 'snafu',
email: 'email' email: 'email'
}).then((user) => { }).then(user => {
return user.reload(); return user.reload();
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('snafu'); expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email'); expect(user.get('email')).to.equal('email');
const testDate = new Date(); const testDate = new Date();
...@@ -209,7 +209,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -209,7 +209,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: DataTypes.STRING email: DataTypes.STRING
}); });
User.beforeUpdate((instance) => { User.beforeUpdate(instance => {
instance.set('email', 'B'); instance.set('email', 'B');
}); });
...@@ -218,14 +218,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -218,14 +218,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A', name: 'A',
bio: 'A', bio: 'A',
email: 'A' email: 'A'
}).then((user) => { }).then(user => {
return user.update({ return user.update({
name: 'B', name: 'B',
bio: 'B' bio: 'B'
}); });
}).then(() => { }).then(() => {
return User.findOne({}); return User.findOne({});
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('B'); expect(user.get('name')).to.equal('B');
expect(user.get('bio')).to.equal('B'); expect(user.get('bio')).to.equal('B');
expect(user.get('email')).to.equal('B'); expect(user.get('email')).to.equal('B');
...@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: DataTypes.STRING email: DataTypes.STRING
}); });
User.beforeUpdate((instance) => { User.beforeUpdate(instance => {
instance.set('email', 'C'); instance.set('email', 'C');
}); });
...@@ -249,7 +249,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -249,7 +249,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A', name: 'A',
bio: 'A', bio: 'A',
email: 'A' email: 'A'
}).then((user) => { }).then(user => {
return user.update({ return user.update({
name: 'B', name: 'B',
bio: 'B', bio: 'B',
...@@ -257,7 +257,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -257,7 +257,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
}); });
}).then(() => { }).then(() => {
return User.findOne({}); return User.findOne({});
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('B'); expect(user.get('name')).to.equal('B');
expect(user.get('bio')).to.equal('B'); expect(user.get('bio')).to.equal('B');
expect(user.get('email')).to.equal('C'); expect(user.get('email')).to.equal('C');
...@@ -277,7 +277,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -277,7 +277,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
} }
}); });
User.beforeUpdate((instance) => { User.beforeUpdate(instance => {
instance.set('email', 'B'); instance.set('email', 'B');
}); });
...@@ -286,12 +286,12 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -286,12 +286,12 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A', name: 'A',
bio: 'A', bio: 'A',
email: 'valid.email@gmail.com' email: 'valid.email@gmail.com'
}).then((user) => { }).then(user => {
return expect(user.update({ return expect(user.update({
name: 'B' name: 'B'
})).to.be.rejectedWith(Sequelize.ValidationError); })).to.be.rejectedWith(Sequelize.ValidationError);
}).then(() => { }).then(() => {
return User.findOne({}).then((user) => { return User.findOne({}).then(user => {
expect(user.get('email')).to.equal('valid.email@gmail.com'); expect(user.get('email')).to.equal('valid.email@gmail.com');
}); });
}); });
...@@ -310,7 +310,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -310,7 +310,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
} }
}); });
User.beforeUpdate((instance) => { User.beforeUpdate(instance => {
instance.set('email', 'B'); instance.set('email', 'B');
}); });
...@@ -319,13 +319,13 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -319,13 +319,13 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A', name: 'A',
bio: 'A', bio: 'A',
email: 'valid.email@gmail.com' email: 'valid.email@gmail.com'
}).then((user) => { }).then(user => {
return expect(user.update({ return expect(user.update({
name: 'B', name: 'B',
email: 'still.valid.email@gmail.com' email: 'still.valid.email@gmail.com'
})).to.be.rejectedWith(Sequelize.ValidationError); })).to.be.rejectedWith(Sequelize.ValidationError);
}).then(() => { }).then(() => {
return User.findOne({}).then((user) => { return User.findOne({}).then(user => {
expect(user.get('email')).to.equal('valid.email@gmail.com'); expect(user.get('email')).to.equal('valid.email@gmail.com');
}); });
}); });
...@@ -344,14 +344,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -344,14 +344,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return User.create({ return User.create({
name: 'snafu', name: 'snafu',
email: 'email' email: 'email'
}).then((user) => { }).then(user => {
return user.update({ return user.update({
bio: 'heyo', bio: 'heyo',
email: 'heho' email: 'heho'
}, { }, {
fields: ['bio'] fields: ['bio']
}); });
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('snafu'); expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email'); expect(user.get('email')).to.equal('email');
expect(user.get('bio')).to.equal('heyo'); expect(user.get('bio')).to.equal('heyo');
...@@ -360,17 +360,17 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -360,17 +360,17 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
}); });
it('updates attributes in the database', function() { it('updates attributes in the database', function() {
return this.User.create({ username: 'user' }).then((user) => { return this.User.create({ username: 'user' }).then(user => {
expect(user.username).to.equal('user'); expect(user.username).to.equal('user');
return user.update({ username: 'person' }).then((user) => { return user.update({ username: 'person' }).then(user => {
expect(user.username).to.equal('person'); expect(user.username).to.equal('person');
}); });
}); });
}); });
it('ignores unknown attributes', function() { it('ignores unknown attributes', function() {
return this.User.create({ username: 'user' }).then((user) => { return this.User.create({ username: 'user' }).then(user => {
return user.update({ username: 'person', foo: 'bar'}).then((user) => { return user.update({ username: 'person', foo: 'bar'}).then(user => {
expect(user.username).to.equal('person'); expect(user.username).to.equal('person');
expect(user.foo).not.to.exist; expect(user.foo).not.to.exist;
}); });
...@@ -399,7 +399,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -399,7 +399,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'foobar', name: 'foobar',
createdAt: new Date(2000, 1, 1), createdAt: new Date(2000, 1, 1),
identifier: 'another identifier' identifier: 'another identifier'
}).then((user) => { }).then(user => {
expect(new Date(user.createdAt)).to.equalDate(new Date(oldCreatedAt)); expect(new Date(user.createdAt)).to.equalDate(new Date(oldCreatedAt));
expect(new Date(user.updatedAt)).to.not.equalTime(new Date(oldUpdatedAt)); expect(new Date(user.updatedAt)).to.not.equalTime(new Date(oldUpdatedAt));
expect(user.identifier).to.equal(oldIdentifier); expect(user.identifier).to.equal(oldIdentifier);
...@@ -417,22 +417,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -417,22 +417,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return Download.sync().then(() => { return Download.sync().then(() => {
return Download.create({ return Download.create({
startedAt: new Date() startedAt: new Date()
}).then((download) => { }).then(download => {
expect(download.startedAt instanceof Date).to.be.true; expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt).to.not.be.ok; expect(download.canceledAt).to.not.be.ok;
expect(download.finishedAt).to.not.be.ok; expect(download.finishedAt).to.not.be.ok;
return download.update({ return download.update({
canceledAt: new Date() canceledAt: new Date()
}).then((download) => { }).then(download => {
expect(download.startedAt instanceof Date).to.be.true; expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt instanceof Date).to.be.true; expect(download.canceledAt instanceof Date).to.be.true;
expect(download.finishedAt).to.not.be.ok; expect(download.finishedAt).to.not.be.ok;
return Download.findAll({ return Download.findAll({
where: {finishedAt: null} where: {finishedAt: null}
}).then((downloads) => { }).then(downloads => {
downloads.forEach((download) => { downloads.forEach(download => {
expect(download.startedAt instanceof Date).to.be.true; expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt instanceof Date).to.be.true; expect(download.canceledAt instanceof Date).to.be.true;
expect(download.finishedAt).to.not.be.ok; expect(download.finishedAt).to.not.be.ok;
...@@ -446,7 +446,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -446,7 +446,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
it('should support logging', function() { it('should support logging', function() {
const spy = sinon.spy(); const spy = sinon.spy();
return this.User.create({}).then((user) => { return this.User.create({}).then(user => {
return user.update({username: 'yolo'}, {logging: spy}).then(() => { return user.update({username: 'yolo'}, {logging: spy}).then(() => {
expect(spy.called).to.be.ok; expect(spy.called).to.be.ok;
}); });
......
...@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => { ...@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
}, {timestamps: false}); }, {timestamps: false});
return User.sync({ force: true }).then(() => { return User.sync({ force: true }).then(() => {
return User.create({}).then((user) => { return User.create({}).then(user => {
// Create the user first to set the proper default values. PG does not support column references in insert, // Create the user first to set the proper default values. PG does not support column references in insert,
// so we must create a record with the right value for always_false, then reference it in an update // so we must create a record with the right value for always_false, then reference it in an update
let now = dialect === 'sqlite' ? self.sequelize.fn('', self.sequelize.fn('datetime', 'now')) : self.sequelize.fn('NOW'); let now = dialect === 'sqlite' ? self.sequelize.fn('', self.sequelize.fn('datetime', 'now')) : self.sequelize.fn('NOW');
...@@ -313,7 +313,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => { ...@@ -313,7 +313,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
}); });
expect(contact.get('tags')).to.deep.equal(['yes', 'no']); expect(contact.get('tags')).to.deep.equal(['yes', 'no']);
return contact.save().then((me) => { return contact.save().then(me => {
expect(me.get('tags')).to.deep.equal(['yes', 'no']); expect(me.get('tags')).to.deep.equal(['yes', 'no']);
}); });
}); });
...@@ -439,7 +439,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => { ...@@ -439,7 +439,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
}); });
return User.sync().then(() => { return User.sync().then(() => {
return User.create({name: 'Jan Meier'}).then((user) => { return User.create({name: 'Jan Meier'}).then(user => {
expect(user.changed('name')).to.be.false; expect(user.changed('name')).to.be.false;
expect(user.changed()).not.to.be.ok; expect(user.changed()).not.to.be.ok;
}); });
...@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => { ...@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
}); });
let changed; let changed;
User.afterUpdate((instance) => { User.afterUpdate(instance => {
changed = instance.changed(); changed = instance.changed();
return; return;
}); });
...@@ -494,11 +494,11 @@ describe(Support.getTestDialectTeaser('DAO'), () => { ...@@ -494,11 +494,11 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
return User.create({ return User.create({
name: 'Ford Prefect' name: 'Ford Prefect'
}); });
}).then((user) => { }).then(user => {
return user.update({ return user.update({
name: 'Arthur Dent' name: 'Arthur Dent'
}); });
}).then((user) => { }).then(user => {
expect(changed).to.be.ok; expect(changed).to.be.ok;
expect(changed.length).to.be.ok; expect(changed.length).to.be.ok;
expect(changed.indexOf('name') > -1).to.be.ok; expect(changed.indexOf('name') > -1).to.be.ok;
......
...@@ -54,7 +54,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -54,7 +54,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return student.addCourse(course, { through: {score: 98, test_value: 1000}}); return student.addCourse(course, { through: {score: 98, test_value: 1000}});
}).then(() => { }).then(() => {
expect(self.callCount).to.equal(1); expect(self.callCount).to.equal(1);
return self.Score.find({ where: { StudentId: 1, CourseId: 100 } }).then((score) => { return self.Score.find({ where: { StudentId: 1, CourseId: 100 } }).then(score => {
expect(score.test_value).to.equal(1001); expect(score.test_value).to.equal(1001);
}); });
}) })
......
...@@ -174,14 +174,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -174,14 +174,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this return this
.ModelUnderTest .ModelUnderTest
.describe() .describe()
.then((fields) => { .then(fields => {
expect(fields.identifier).to.include({ allowNull: false }); expect(fields.identifier).to.include({ allowNull: false });
}); });
}); });
}); });
it('should support instance.destroy()', function() { it('should support instance.destroy()', function() {
return this.User.create().then((user) => { return this.User.create().then(user => {
return user.destroy(); return user.destroy();
}); });
}); });
...@@ -206,32 +206,32 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -206,32 +206,32 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('bulkCreate should work', function() { it('bulkCreate should work', function() {
return this.Comment.findAll().then((comments) => { return this.Comment.findAll().then(comments => {
expect(comments[0].notes).to.equal('Number one'); expect(comments[0].notes).to.equal('Number one');
expect(comments[1].notes).to.equal('Number two'); expect(comments[1].notes).to.equal('Number two');
}); });
}); });
it('find with where should work', function() { it('find with where should work', function() {
return this.Comment.findAll({ where: { notes: 'Number one' }}).then((comments) => { return this.Comment.findAll({ where: { notes: 'Number one' }}).then(comments => {
expect(comments).to.have.length(1); expect(comments).to.have.length(1);
expect(comments[0].notes).to.equal('Number one'); expect(comments[0].notes).to.equal('Number one');
}); });
}); });
it('reload should work', function() { it('reload should work', function() {
return this.Comment.findById(1).then((comment) => { return this.Comment.findById(1).then(comment => {
return comment.reload(); return comment.reload();
}); });
}); });
it('save should work', function() { it('save should work', function() {
return this.Comment.create({ notes: 'my note' }).then((comment) => { return this.Comment.create({ notes: 'my note' }).then(comment => {
comment.notes = 'new note'; comment.notes = 'new note';
return comment.save(); return comment.save();
}).then((comment) => { }).then(comment => {
return comment.reload(); return comment.reload();
}).then((comment) => { }).then(comment => {
expect(comment.notes).to.equal('new note'); expect(comment.notes).to.equal('new note');
}); });
}); });
...@@ -275,7 +275,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -275,7 +275,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.User.find({ return self.User.find({
limit: 1 limit: 1
}); });
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('Foobar'); expect(user.get('name')).to.equal('Foobar');
return user.updateAttributes({ return user.updateAttributes({
name: 'Barfoo' name: 'Barfoo'
...@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.User.find({ return self.User.find({
limit: 1 limit: 1
}); });
}).then((user) => { }).then(user => {
expect(user.get('name')).to.equal('Barfoo'); expect(user.get('name')).to.equal('Barfoo');
}); });
}); });
...@@ -306,7 +306,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -306,7 +306,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
where: { where: {
strField: 'bar' strField: 'bar'
} }
}).then((entity) => { }).then(entity => {
expect(entity).to.be.ok; expect(entity).to.be.ok;
expect(entity.get('strField')).to.equal('bar'); expect(entity.get('strField')).to.equal('bar');
}); });
...@@ -336,7 +336,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -336,7 +336,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
return Model.sync({force: true}).then(() => { return Model.sync({force: true}).then(() => {
return Model.create({title: 'test'}).then((data) => { return Model.create({title: 'test'}).then(data => {
expect(data.get('test_title')).to.be.an('undefined'); expect(data.get('test_title')).to.be.an('undefined');
expect(data.get('test_id')).to.be.an('undefined'); expect(data.get('test_id')).to.be.an('undefined');
}); });
...@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should make the aliased auto incremented primary key available after create', function() { it('should make the aliased auto incremented primary key available after create', function() {
return this.User.create({ return this.User.create({
name: 'Barfoo' name: 'Barfoo'
}).then((user) => { }).then(user => {
expect(user.get('id')).to.be.ok; expect(user.get('id')).to.be.ok;
}); });
}); });
...@@ -356,11 +356,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -356,11 +356,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.create({ return this.User.create({
name: 'Barfoo' name: 'Barfoo'
}).then((user) => { }).then(user => {
return user.createTask({ return user.createTask({
title: 'DatDo' title: 'DatDo'
}); });
}).then((task) => { }).then(task => {
return task.createComment({ return task.createComment({
text: 'Comment' text: 'Comment'
}); });
...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
], ],
where: {title: 'DatDo'} where: {title: 'DatDo'}
}); });
}).then((task) => { }).then(task => {
expect(task.get('title')).to.equal('DatDo'); expect(task.get('title')).to.equal('DatDo');
expect(task.get('comments')[0].get('text')).to.equal('Comment'); expect(task.get('comments')[0].get('text')).to.equal('Comment');
expect(task.get('user')).to.be.ok; expect(task.get('user')).to.be.ok;
...@@ -384,11 +384,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -384,11 +384,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.create({ return this.User.create({
name: 'Foobar' name: 'Foobar'
}).then((user) => { }).then(user => {
return user.createTask({ return user.createTask({
title: 'DoDat' title: 'DoDat'
}); });
}).then((task) => { }).then(task => {
return task.createComment({ return task.createComment({
text: 'Comment' text: 'Comment'
}); });
...@@ -400,8 +400,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -400,8 +400,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
]} ]}
] ]
}); });
}).then((users) => { }).then(users => {
users.forEach((user) => { users.forEach(user => {
expect(user.get('name')).to.be.ok; expect(user.get('name')).to.be.ok;
expect(user.get('tasks')[0].get('title')).to.equal('DoDat'); expect(user.get('tasks')[0].get('title')).to.equal('DoDat');
expect(user.get('tasks')[0].get('comments')).to.be.ok; expect(user.get('tasks')[0].get('comments')).to.be.ok;
...@@ -410,7 +410,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -410,7 +410,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should work with increment', function() { it('should work with increment', function() {
return this.User.create().then((user) => { return this.User.create().then(user => {
return user.increment('taskCount'); return user.increment('taskCount');
}); });
}); });
...@@ -426,7 +426,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -426,7 +426,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Foobar' name: 'Foobar'
} }
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -444,7 +444,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -444,7 +444,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Lollerskates' name: 'Lollerskates'
}) })
}); });
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
}); });
}); });
...@@ -459,8 +459,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -459,8 +459,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Cde' name: 'Cde'
}]).then(() => { }]).then(() => {
return self.User.findAll(); return self.User.findAll();
}).then((users) => { }).then(users => {
users.forEach((user) => { users.forEach(user => {
expect(['Abc', 'Bcd', 'Cde'].indexOf(user.get('name')) !== -1).to.be.true; expect(['Abc', 'Bcd', 'Cde'].indexOf(user.get('name')) !== -1).to.be.true;
}); });
}); });
...@@ -491,7 +491,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -491,7 +491,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
attributes: findAttributes attributes: findAttributes
}); });
}).then((tests) => { }).then(tests => {
expect(tests[0].get('someProperty')).to.be.ok; expect(tests[0].get('someProperty')).to.be.ok;
expect(tests[0].get('someProperty2')).to.be.ok; expect(tests[0].get('someProperty2')).to.be.ok;
}); });
...@@ -511,7 +511,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -511,7 +511,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
.then(() => { .then(() => {
return this.User.find({ where: { name: 'test user' } }); return this.User.find({ where: { name: 'test user' } });
}) })
.then((user) => { .then(user => {
expect(user.name).to.equal('test user'); expect(user.name).to.equal('test user');
}); });
}); });
...@@ -525,7 +525,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -525,7 +525,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.Comment.find({ return self.Comment.find({
limit: 1 limit: 1
}); });
}).then((comment) => { }).then(comment => {
expect(comment.get('notes')).to.equal('Foobar'); expect(comment.get('notes')).to.equal('Foobar');
return comment.updateAttributes({ return comment.updateAttributes({
notes: 'Barfoo' notes: 'Barfoo'
...@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.Comment.find({ return self.Comment.find({
limit: 1 limit: 1
}); });
}).then((comment) => { }).then(comment => {
expect(comment.get('notes')).to.equal('Barfoo'); expect(comment.get('notes')).to.equal('Barfoo');
}); });
}); });
...@@ -573,14 +573,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -573,14 +573,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
.then(() => { .then(() => {
return User.create(); return User.create();
}) })
.then((user) => { .then(user => {
return user.destroy(); return user.destroy();
}) })
.then(function() { .then(function() {
this.clock.tick(1000); this.clock.tick(1000);
return User.findAll(); return User.findAll();
}) })
.then((users) => { .then(users => {
expect(users.length).to.equal(0); expect(users.length).to.equal(0);
}); });
}); });
...@@ -597,10 +597,10 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -597,10 +597,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
return User.sync({force: true}).then(() => { return User.sync({force: true}).then(() => {
return User.create().then((user) => { return User.create().then(user => {
return User.destroy({where: {id: user.get('id')}}); return User.destroy({where: {id: user.get('id')}});
}).then(() => { }).then(() => {
return User.findAll().then((users) => { return User.findAll().then(users => {
expect(users.length).to.equal(0); expect(users.length).to.equal(0);
}); });
}); });
......
...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be ignored in table creation', function() { it('should be ignored in table creation', function() {
return this.sequelize.getQueryInterface().describeTable(this.User.tableName).then((fields) => { return this.sequelize.getQueryInterface().describeTable(this.User.tableName).then(fields => {
expect(Object.keys(fields).length).to.equal(2); expect(Object.keys(fields).length).to.equal(2);
}); });
}); });
...@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return Post.find({ attributes: ['id', 'text', Sequelize.literal(boolQuery)] }); return Post.find({ attributes: ['id', 'text', Sequelize.literal(boolQuery)] });
}).then((post) => { }).then(post => {
expect(post.get('someBoolean')).to.be.ok; expect(post.get('someBoolean')).to.be.ok;
expect(post.get().someBoolean).to.be.ok; expect(post.get().someBoolean).to.be.ok;
}); });
...@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be ignored in create and updateAttributes', function() { it('should be ignored in create and updateAttributes', function() {
return this.User.create({ return this.User.create({
field1: 'something' field1: 'something'
}).then((user) => { }).then(user => {
// We already verified that the virtual is not added to the table definition, so if this succeeds, were good // We already verified that the virtual is not added to the table definition, so if this succeeds, were good
expect(user.virtualWithDefault).to.equal('cake'); expect(user.virtualWithDefault).to.equal('cake');
...@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, { }, {
fields: ['storage'] fields: ['storage']
}); });
}).then((user) => { }).then(user => {
expect(user.virtualWithDefault).to.equal('cake'); expect(user.virtualWithDefault).to.equal('cake');
expect(user.storage).to.equal('something else'); expect(user.storage).to.equal('something else');
}); });
...@@ -139,7 +139,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -139,7 +139,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
logging: this.sqlAssert logging: this.sqlAssert
}).then(() => { }).then(() => {
return self.User.findAll(); return self.User.findAll();
}).then((users) => { }).then(users => {
expect(users[0].storage).to.equal('something'); expect(users[0].storage).to.equal('something');
}); });
}); });
......
...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
{username: 'boo2'} {username: 'boo2'}
]).then(() => { ]).then(() => {
return self.User.findOne(); return self.User.findOne();
}).then((user) => { }).then(user => {
return user.createProject({ return user.createProject({
name: 'project1' name: 'project1'
}); });
...@@ -62,7 +62,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -62,7 +62,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
group: ['createdAt'] group: ['createdAt']
}) })
) )
.then((users) => { .then(users => {
expect(users.length).to.be.eql(2); expect(users.length).to.be.eql(2);
// have attributes // have attributes
...@@ -87,20 +87,20 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -87,20 +87,20 @@ describe(Support.getTestDialectTeaser('Model'), () => {
order: ['age'] order: ['age']
}) })
) )
.then((result) => { .then(result => {
expect(parseInt(result[0].count)).to.be.eql(2); expect(parseInt(result[0].count)).to.be.eql(2);
return this.User.count({ return this.User.count({
where: { username: 'fire' } where: { username: 'fire' }
}); });
}) })
.then((count) => { .then(count => {
expect(count).to.be.eql(0); expect(count).to.be.eql(0);
return this.User.count({ return this.User.count({
where: { username: 'fire' }, where: { username: 'fire' },
group: 'age' group: 'age'
}); });
}) })
.then((count) => { .then(count => {
expect(count).to.be.eql([]); expect(count).to.be.eql([]);
}); });
}); });
...@@ -119,14 +119,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -119,14 +119,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
col: 'username' col: 'username'
}) })
) )
.then((count) => { .then(count => {
expect(parseInt(count)).to.be.eql(3); expect(parseInt(count)).to.be.eql(3);
return this.User.count({ return this.User.count({
col: 'age', col: 'age',
distinct: true distinct: true
}); });
}) })
.then((count) => { .then(count => {
expect(parseInt(count)).to.be.eql(2); expect(parseInt(count)).to.be.eql(2);
}); });
}); });
...@@ -139,11 +139,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -139,11 +139,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
'$Projects.name$': 'project1' '$Projects.name$': 'project1'
} }
}; };
return this.User.count(queryObject).then((count) => { return this.User.count(queryObject).then(count => {
expect(parseInt(count)).to.be.eql(1); expect(parseInt(count)).to.be.eql(1);
queryObject.where['$Projects.name$'] = 'project2'; queryObject.where['$Projects.name$'] = 'project2';
return this.User.count(queryObject); return this.User.count(queryObject);
}).then((count) => { }).then(count => {
expect(parseInt(count)).to.be.eql(0); expect(parseInt(count)).to.be.eql(0);
}); });
}); });
...@@ -161,14 +161,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -161,14 +161,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
distinct: true, distinct: true,
include: [this.Project] include: [this.Project]
}) })
).then((count) => { ).then(count => {
expect(parseInt(count)).to.be.eql(3); expect(parseInt(count)).to.be.eql(3);
return this.User.count({ return this.User.count({
col: 'age', col: 'age',
distinct: true, distinct: true,
include: [this.Project] include: [this.Project]
}); });
}).then((count) => expect(parseInt(count)).to.be.eql(2)); }).then(count => expect(parseInt(count)).to.be.eql(2));
}); });
}); });
......
...@@ -44,14 +44,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -44,14 +44,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: User, model: User,
myOption: 'option' myOption: 'option'
}] }]
}).then((savedProduct) => { }).then(savedProduct => {
expect(savedProduct.isIncludeCreatedOnAfterCreate).to.be.true; expect(savedProduct.isIncludeCreatedOnAfterCreate).to.be.true;
expect(savedProduct.User.createOptions.myOption).to.be.equal('option'); expect(savedProduct.User.createOptions.myOption).to.be.equal('option');
expect(savedProduct.User.createOptions.parentRecord).to.be.equal(savedProduct); expect(savedProduct.User.createOptions.parentRecord).to.be.equal(savedProduct);
return Product.findOne({ return Product.findOne({
where: { id: savedProduct.id }, where: { id: savedProduct.id },
include: [ User ] include: [ User ]
}).then((persistedProduct) => { }).then(persistedProduct => {
expect(persistedProduct.User).to.be.ok; expect(persistedProduct.User).to.be.ok;
expect(persistedProduct.User.first_name).to.be.equal('Mick'); expect(persistedProduct.User.first_name).to.be.equal('Mick');
expect(persistedProduct.User.last_name).to.be.equal('Broadstone'); expect(persistedProduct.User.last_name).to.be.equal('Broadstone');
...@@ -80,11 +80,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -80,11 +80,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
}, { }, {
include: [ Creator ] include: [ Creator ]
}).then((savedProduct) => { }).then(savedProduct => {
return Product.findOne({ return Product.findOne({
where: { id: savedProduct.id }, where: { id: savedProduct.id },
include: [ Creator ] include: [ Creator ]
}).then((persistedProduct) => { }).then(persistedProduct => {
expect(persistedProduct.creator).to.be.ok; expect(persistedProduct.creator).to.be.ok;
expect(persistedProduct.creator.first_name).to.be.equal('Matt'); expect(persistedProduct.creator.first_name).to.be.equal('Matt');
expect(persistedProduct.creator.last_name).to.be.equal('Hansen'); expect(persistedProduct.creator.last_name).to.be.equal('Hansen');
...@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
hooks: { hooks: {
afterCreate(product) { afterCreate(product) {
product.areIncludesCreatedOnAfterCreate = product.Tags && product.areIncludesCreatedOnAfterCreate = product.Tags &&
product.Tags.every((tag) => { product.Tags.every(tag => {
return !!tag.id; return !!tag.id;
}); });
} }
...@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: Tag, model: Tag,
myOption: 'option' myOption: 'option'
}] }]
}).then((savedProduct) => { }).then(savedProduct => {
expect(savedProduct.areIncludesCreatedOnAfterCreate).to.be.true; expect(savedProduct.areIncludesCreatedOnAfterCreate).to.be.true;
expect(savedProduct.Tags[0].createOptions.myOption).to.be.equal('option'); expect(savedProduct.Tags[0].createOptions.myOption).to.be.equal('option');
expect(savedProduct.Tags[0].createOptions.parentRecord).to.be.equal(savedProduct); expect(savedProduct.Tags[0].createOptions.parentRecord).to.be.equal(savedProduct);
...@@ -140,7 +140,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -140,7 +140,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Product.find({ return Product.find({
where: { id: savedProduct.id }, where: { id: savedProduct.id },
include: [ Tag ] include: [ Tag ]
}).then((persistedProduct) => { }).then(persistedProduct => {
expect(persistedProduct.Tags).to.be.ok; expect(persistedProduct.Tags).to.be.ok;
expect(persistedProduct.Tags.length).to.equal(2); expect(persistedProduct.Tags.length).to.equal(2);
}); });
...@@ -168,11 +168,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -168,11 +168,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
] ]
}, { }, {
include: [ Categories ] include: [ Categories ]
}).then((savedProduct) => { }).then(savedProduct => {
return Product.find({ return Product.find({
where: { id: savedProduct.id }, where: { id: savedProduct.id },
include: [ Categories ] include: [ Categories ]
}).then((persistedProduct) => { }).then(persistedProduct => {
expect(persistedProduct.categories).to.be.ok; expect(persistedProduct.categories).to.be.ok;
expect(persistedProduct.categories.length).to.equal(2); expect(persistedProduct.categories.length).to.equal(2);
}); });
...@@ -199,11 +199,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -199,11 +199,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
}, { }, {
include: [ Task ] include: [ Task ]
}).then((savedUser) => { }).then(savedUser => {
return User.find({ return User.find({
where: { id: savedUser.id }, where: { id: savedUser.id },
include: [ Task ] include: [ Task ]
}).then((persistedUser) => { }).then(persistedUser => {
expect(persistedUser.Task).to.be.ok; expect(persistedUser.Task).to.be.ok;
}); });
}); });
...@@ -230,11 +230,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -230,11 +230,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
}, { }, {
include: [ Job ] include: [ Job ]
}).then((savedUser) => { }).then(savedUser => {
return User.find({ return User.find({
where: { id: savedUser.id }, where: { id: savedUser.id },
include: [ Job ] include: [ Job ]
}).then((persistedUser) => { }).then(persistedUser => {
expect(persistedUser.job).to.be.ok; expect(persistedUser.job).to.be.ok;
}); });
}); });
...@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
hooks: { hooks: {
afterCreate(user) { afterCreate(user) {
user.areIncludesCreatedOnAfterCreate = user.Tasks && user.areIncludesCreatedOnAfterCreate = user.Tasks &&
user.Tasks.every((task) => { user.Tasks.every(task => {
return !!task.id; return !!task.id;
}); });
} }
...@@ -281,7 +281,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -281,7 +281,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: Task, model: Task,
myOption: 'option' myOption: 'option'
}] }]
}).then((savedUser) => { }).then(savedUser => {
expect(savedUser.areIncludesCreatedOnAfterCreate).to.be.true; expect(savedUser.areIncludesCreatedOnAfterCreate).to.be.true;
expect(savedUser.Tasks[0].createOptions.myOption).to.be.equal('option'); expect(savedUser.Tasks[0].createOptions.myOption).to.be.equal('option');
expect(savedUser.Tasks[0].createOptions.parentRecord).to.be.equal(savedUser); expect(savedUser.Tasks[0].createOptions.parentRecord).to.be.equal(savedUser);
...@@ -290,7 +290,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -290,7 +290,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.find({ return User.find({
where: { id: savedUser.id }, where: { id: savedUser.id },
include: [ Task ] include: [ Task ]
}).then((persistedUser) => { }).then(persistedUser => {
expect(persistedUser.Tasks).to.be.ok; expect(persistedUser.Tasks).to.be.ok;
expect(persistedUser.Tasks.length).to.equal(2); expect(persistedUser.Tasks.length).to.equal(2);
}); });
...@@ -378,18 +378,18 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -378,18 +378,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}] }]
} }
); );
}).then((savedPost) => { }).then(savedPost => {
// The saved post should include the two tags // The saved post should include the two tags
expect(savedPost.tags.length).to.equal(2); expect(savedPost.tags.length).to.equal(2);
// The saved post should be able to retrieve the two tags // The saved post should be able to retrieve the two tags
// using the convenience accessor methods // using the convenience accessor methods
return savedPost.getTags(); return savedPost.getTags();
}).then((savedTags) => { }).then(savedTags => {
// All nested tags should be returned // All nested tags should be returned
expect(savedTags.length).to.equal(2); expect(savedTags.length).to.equal(2);
}).then(() => { }).then(() => {
return ItemTag.findAll(); return ItemTag.findAll();
}).then((itemTags) => { }).then(itemTags => {
// Two "through" models should be created // Two "through" models should be created
expect(itemTags.length).to.equal(2); expect(itemTags.length).to.equal(2);
// And their polymorphic field should be correctly set to 'post' // And their polymorphic field should be correctly set to 'post'
...@@ -420,11 +420,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -420,11 +420,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
] ]
}, { }, {
include: [ Jobs ] include: [ Jobs ]
}).then((savedUser) => { }).then(savedUser => {
return User.find({ return User.find({
where: { id: savedUser.id }, where: { id: savedUser.id },
include: [ Jobs ] include: [ Jobs ]
}).then((persistedUser) => { }).then(persistedUser => {
expect(persistedUser.jobs).to.be.ok; expect(persistedUser.jobs).to.be.ok;
expect(persistedUser.jobs.length).to.equal(2); expect(persistedUser.jobs.length).to.equal(2);
}); });
......
...@@ -46,7 +46,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -46,7 +46,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
], ],
group: [ 'Post.id' ] group: [ 'Post.id' ]
}); });
}).then((posts) => { }).then(posts => {
expect(parseInt(posts[0].get('comment_count'))).to.be.equal(3); expect(parseInt(posts[0].get('comment_count'))).to.be.equal(3);
expect(parseInt(posts[1].get('comment_count'))).to.be.equal(2); expect(parseInt(posts[1].get('comment_count'))).to.be.equal(2);
}); });
......
...@@ -26,9 +26,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -26,9 +26,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should work with order: literal()', function() { it('should work with order: literal()', function() {
return this.User.findAll({ return this.User.findAll({
order: this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com')) order: this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.get('email')).to.be.ok; expect(user.get('email')).to.be.ok;
}); });
}); });
...@@ -37,9 +37,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -37,9 +37,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should work with order: [literal()]', function() { it('should work with order: [literal()]', function() {
return this.User.findAll({ return this.User.findAll({
order: [this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))] order: [this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))]
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.get('email')).to.be.ok; expect(user.get('email')).to.be.ok;
}); });
}); });
...@@ -50,9 +50,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -50,9 +50,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
order: [ order: [
[this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))] [this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))]
] ]
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
users.forEach((user) => { users.forEach(user => {
expect(user.get('email')).to.be.ok; expect(user.get('email')).to.be.ok;
}); });
}); });
......
...@@ -27,7 +27,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -27,7 +27,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Pub.sync({ force: true }).then(() => { return Pub.sync({ force: true }).then(() => {
return Pub.create({location: point}); return Pub.create({location: point});
}).then((pub) => { }).then(pub => {
expect(pub).not.to.be.null; expect(pub).not.to.be.null;
expect(pub.location).to.be.deep.eql(point); expect(pub.location).to.be.deep.eql(point);
}); });
...@@ -37,7 +37,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -37,7 +37,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'Point', coordinates: [39.807222, -76.984722]}; const point = { type: 'Point', coordinates: [39.807222, -76.984722]};
return User.create({username: 'username', geography: point }).then((newUser) => { return User.create({username: 'username', geography: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geography).to.be.deep.eql(point); expect(newUser.geography).to.be.deep.eql(point);
}); });
...@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}}); return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geography).to.be.deep.eql(point2); expect(user.geography).to.be.deep.eql(point2);
}); });
}); });
...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'Point', coordinates: [39.807222, -76.984722]}; const point = { type: 'Point', coordinates: [39.807222, -76.984722]};
return User.create({username: 'username', geography: point }).then((newUser) => { return User.create({username: 'username', geography: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geography).to.be.deep.eql(point); expect(newUser.geography).to.be.deep.eql(point);
}); });
...@@ -89,7 +89,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -89,7 +89,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}}); return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geography).to.be.deep.eql(point2); expect(user.geography).to.be.deep.eql(point2);
}); });
}); });
...@@ -109,7 +109,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -109,7 +109,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] }; const point = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] };
return User.create({username: 'username', geography: point }).then((newUser) => { return User.create({username: 'username', geography: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geography).to.be.deep.eql(point); expect(newUser.geography).to.be.deep.eql(point);
}); });
...@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}}); return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geography).to.be.deep.eql(point2); expect(user.geography).to.be.deep.eql(point2);
}); });
}); });
...@@ -148,7 +148,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -148,7 +148,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
[100.0, 1.0], [100.0, 0.0] ] [100.0, 1.0], [100.0, 0.0] ]
]}; ]};
return User.create({username: 'username', geography: point }).then((newUser) => { return User.create({username: 'username', geography: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geography).to.be.deep.eql(point); expect(newUser.geography).to.be.deep.eql(point);
}); });
...@@ -170,7 +170,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -170,7 +170,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: polygon2}, {where: {username: props.username}}); return User.update({geography: polygon2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geography).to.be.deep.eql(polygon2); expect(user.geography).to.be.deep.eql(polygon2);
}); });
}); });
......
...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Pub.sync({ force: true }).then(() => { return Pub.sync({ force: true }).then(() => {
return Pub.create({location: point}); return Pub.create({location: point});
}).then((pub) => { }).then(pub => {
expect(pub).not.to.be.null; expect(pub).not.to.be.null;
expect(pub.location).to.be.deep.eql(point); expect(pub.location).to.be.deep.eql(point);
}); });
...@@ -39,7 +39,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -39,7 +39,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'Point', coordinates: [39.807222, -76.984722]}; const point = { type: 'Point', coordinates: [39.807222, -76.984722]};
return User.create({username: 'username', geometry: point }).then((newUser) => { return User.create({username: 'username', geometry: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geometry).to.be.deep.eql(point); expect(newUser.geometry).to.be.deep.eql(point);
}); });
...@@ -55,7 +55,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -55,7 +55,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}}); return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geometry).to.be.deep.eql(point2); expect(user.geometry).to.be.deep.eql(point2);
}); });
}); });
...@@ -75,7 +75,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -75,7 +75,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'Point', coordinates: [39.807222, -76.984722]}; const point = { type: 'Point', coordinates: [39.807222, -76.984722]};
return User.create({username: 'username', geometry: point }).then((newUser) => { return User.create({username: 'username', geometry: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geometry).to.be.deep.eql(point); expect(newUser.geometry).to.be.deep.eql(point);
}); });
...@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}}); return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geometry).to.be.deep.eql(point2); expect(user.geometry).to.be.deep.eql(point2);
}); });
}); });
...@@ -111,7 +111,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -111,7 +111,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User; const User = this.User;
const point = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] }; const point = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] };
return User.create({username: 'username', geometry: point }).then((newUser) => { return User.create({username: 'username', geometry: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geometry).to.be.deep.eql(point); expect(newUser.geometry).to.be.deep.eql(point);
}); });
...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}}); return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geometry).to.be.deep.eql(point2); expect(user.geometry).to.be.deep.eql(point2);
}); });
}); });
...@@ -150,7 +150,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -150,7 +150,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
[100.0, 1.0], [100.0, 0.0] ] [100.0, 1.0], [100.0, 0.0] ]
]}; ]};
return User.create({username: 'username', geometry: point }).then((newUser) => { return User.create({username: 'username', geometry: point }).then(newUser => {
expect(newUser).not.to.be.null; expect(newUser).not.to.be.null;
expect(newUser.geometry).to.be.deep.eql(point); expect(newUser.geometry).to.be.deep.eql(point);
}); });
...@@ -172,7 +172,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -172,7 +172,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: polygon2}, {where: {username: props.username}}); return User.update({geometry: polygon2}, {where: {username: props.username}});
}).then(() => { }).then(() => {
return User.findOne({where: {username: props.username}}); return User.findOne({where: {username: props.username}});
}).then((user) => { }).then(user => {
expect(user.geometry).to.be.deep.eql(polygon2); expect(user.geometry).to.be.deep.eql(polygon2);
}); });
}); });
......
...@@ -578,7 +578,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -578,7 +578,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
}); });
it('should query an instance with JSONB data and order while trying to inject', function () { it('should query an instance with JSONB data and order while trying to inject', function() {
return this.Event.create({ return this.Event.create({
data: { data: {
name: { name: {
......
...@@ -35,24 +35,24 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -35,24 +35,24 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Account.sync({force: true}) return Account.sync({force: true})
.then(() => Account.create({ ownerId: 12 })) .then(() => Account.create({ ownerId: 12 }))
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }}) return Account.destroy({ where: { ownerId: 12 }})
.then((result) => { .then(result => {
expect(result).to.be.equal(1); expect(result).to.be.equal(1);
}); });
}) })
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(0); expect(count).to.be.equal(0);
return Account.count({ paranoid: false }); return Account.count({ paranoid: false });
}) })
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
return Account.restore({ where: { ownerId: 12 }}); return Account.restore({ where: { ownerId: 12 }});
}) })
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
}); });
}); });
...@@ -83,21 +83,21 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -83,21 +83,21 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Account.sync({force: true}) return Account.sync({force: true})
.then(() => Account.create({ ownerId: 12 })) .then(() => Account.create({ ownerId: 12 }))
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }}); return Account.destroy({ where: { ownerId: 12 }});
}) })
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(0); expect(count).to.be.equal(0);
return Account.count({ paranoid: false }); return Account.count({ paranoid: false });
}) })
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
return Account.restore({ where: { ownerId: 12 }}); return Account.restore({ where: { ownerId: 12 }});
}) })
.then(() => Account.count()) .then(() => Account.count())
.then((count) => { .then(count => {
expect(count).to.be.equal(1); expect(count).to.be.equal(1);
}); });
}); });
......
...@@ -82,15 +82,15 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -82,15 +82,15 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantOne.findOne({ return self.RestaurantOne.findOne({
where: {foo: 'one'} where: {foo: 'one'}
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one'); expect(obj.foo).to.equal('one');
restaurantId = obj.id; restaurantId = obj.id;
return self.RestaurantOne.findById(restaurantId); return self.RestaurantOne.findById(restaurantId);
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one'); expect(obj.foo).to.equal('one');
return self.RestaurantTwo.findOne({where: {foo: 'one'}}).then((RestaurantObj) => { return self.RestaurantTwo.findOne({where: {foo: 'one'}}).then(RestaurantObj => {
expect(RestaurantObj).to.be.null; expect(RestaurantObj).to.be.null;
}); });
}); });
...@@ -107,15 +107,15 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -107,15 +107,15 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantTwo.findOne({ return self.RestaurantTwo.findOne({
where: {foo: 'two'} where: {foo: 'two'}
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('two'); expect(obj.foo).to.equal('two');
restaurantId = obj.id; restaurantId = obj.id;
return self.RestaurantTwo.findById(restaurantId); return self.RestaurantTwo.findById(restaurantId);
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('two'); expect(obj.foo).to.equal('two');
return self.RestaurantOne.findOne({where: {foo: 'two'}}).then((RestaurantObj) => { return self.RestaurantOne.findOne({where: {foo: 'two'}}).then(RestaurantObj => {
expect(RestaurantObj).to.be.null; expect(RestaurantObj).to.be.null;
}); });
}); });
...@@ -145,59 +145,59 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -145,59 +145,59 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return restaurauntModel.save(); return restaurauntModel.save();
}).then(() => { }).then(() => {
return self.RestaurantOne.findAll(); return self.RestaurantOne.findAll();
}).then((restaurantsOne) => { }).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null; expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(2); expect(restaurantsOne.length).to.equal(2);
restaurantsOne.forEach((restaurant) => { restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one'); expect(restaurant.bar).to.contain('one');
}); });
return self.RestaurantOne.findAndCountAll(); return self.RestaurantOne.findAndCountAll();
}).then((restaurantsOne) => { }).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null; expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.rows.length).to.equal(2); expect(restaurantsOne.rows.length).to.equal(2);
expect(restaurantsOne.count).to.equal(2); expect(restaurantsOne.count).to.equal(2);
restaurantsOne.rows.forEach((restaurant) => { restaurantsOne.rows.forEach(restaurant => {
expect(restaurant.bar).to.contain('one'); expect(restaurant.bar).to.contain('one');
}); });
return self.RestaurantOne.findAll({ return self.RestaurantOne.findAll({
where: {bar: {$like: '%.1'}} where: {bar: {$like: '%.1'}}
}); });
}).then((restaurantsOne) => { }).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null; expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(1); expect(restaurantsOne.length).to.equal(1);
restaurantsOne.forEach((restaurant) => { restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one'); expect(restaurant.bar).to.contain('one');
}); });
return self.RestaurantOne.count(); return self.RestaurantOne.count();
}).then((count) => { }).then(count => {
expect(count).to.not.be.null; expect(count).to.not.be.null;
expect(count).to.equal(2); expect(count).to.equal(2);
return self.RestaurantTwo.findAll(); return self.RestaurantTwo.findAll();
}).then((restaurantsTwo) => { }).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null; expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(3); expect(restaurantsTwo.length).to.equal(3);
restaurantsTwo.forEach((restaurant) => { restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two'); expect(restaurant.bar).to.contain('two');
}); });
return self.RestaurantTwo.findAndCountAll(); return self.RestaurantTwo.findAndCountAll();
}).then((restaurantsTwo) => { }).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null; expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.rows.length).to.equal(3); expect(restaurantsTwo.rows.length).to.equal(3);
expect(restaurantsTwo.count).to.equal(3); expect(restaurantsTwo.count).to.equal(3);
restaurantsTwo.rows.forEach((restaurant) => { restaurantsTwo.rows.forEach(restaurant => {
expect(restaurant.bar).to.contain('two'); expect(restaurant.bar).to.contain('two');
}); });
return self.RestaurantTwo.findAll({ return self.RestaurantTwo.findAll({
where: {bar: {$like: '%.3'}} where: {bar: {$like: '%.3'}}
}); });
}).then((restaurantsTwo) => { }).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null; expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(1); expect(restaurantsTwo.length).to.equal(1);
restaurantsTwo.forEach((restaurant) => { restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two'); expect(restaurant.bar).to.contain('two');
}); });
return self.RestaurantTwo.count(); return self.RestaurantTwo.count();
}).then((count) => { }).then(count => {
expect(count).to.not.be.null; expect(count).to.not.be.null;
expect(count).to.equal(3); expect(count).to.equal(3);
}); });
...@@ -211,14 +211,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -211,14 +211,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Location.sync({force: true}) return Location.sync({force: true})
.then(() => { .then(() => {
return Location.create({name: 'HQ'}).then(() => { return Location.create({name: 'HQ'}).then(() => {
return Location.findOne({where: {name: 'HQ'}}).then((obj) => { return Location.findOne({where: {name: 'HQ'}}).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.name).to.equal('HQ'); expect(obj.name).to.equal('HQ');
locationId = obj.id; locationId = obj.id;
}); });
}); });
}) })
.catch((err) => { .catch(err => {
expect(err).to.be.null; expect(err).to.be.null;
}); });
}); });
...@@ -235,7 +235,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -235,7 +235,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.Location, as: 'location' model: self.Location, as: 'location'
}] }]
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one'); expect(obj.foo).to.equal('one');
expect(obj.location).to.not.be.null; expect(obj.location).to.not.be.null;
...@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantOne.findOne({ return self.RestaurantOne.findOne({
where: {foo: 'one'} where: {foo: 'one'}
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one'); expect(obj.foo).to.equal('one');
restaurantId = obj.id; restaurantId = obj.id;
...@@ -279,13 +279,13 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -279,13 +279,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.EmployeeOne, as: 'employees' model: self.EmployeeOne, as: 'employees'
}] }]
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.employees).to.not.be.null; expect(obj.employees).to.not.be.null;
expect(obj.employees.length).to.equal(1); expect(obj.employees.length).to.equal(1);
expect(obj.employees[0].last_name).to.equal('one'); expect(obj.employees[0].last_name).to.equal('one');
return obj.getEmployees({schema:SCHEMA_ONE}); return obj.getEmployees({schema:SCHEMA_ONE});
}).then((employees) => { }).then(employees => {
expect(employees.length).to.equal(1); expect(employees.length).to.equal(1);
expect(employees[0].last_name).to.equal('one'); expect(employees[0].last_name).to.equal('one');
return self.EmployeeOne.findOne({ return self.EmployeeOne.findOne({
...@@ -293,12 +293,12 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -293,12 +293,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.RestaurantOne, as: 'restaurant' model: self.RestaurantOne, as: 'restaurant'
}] }]
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.restaurant).to.not.be.null; expect(obj.restaurant).to.not.be.null;
expect(obj.restaurant.foo).to.equal('one'); expect(obj.restaurant.foo).to.equal('one');
return obj.getRestaurant({schema:SCHEMA_ONE}); return obj.getRestaurant({schema:SCHEMA_ONE});
}).then((restaurant) => { }).then(restaurant => {
expect(restaurant).to.not.be.null; expect(restaurant).to.not.be.null;
expect(restaurant.foo).to.equal('one'); expect(restaurant.foo).to.equal('one');
}); });
...@@ -315,7 +315,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -315,7 +315,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantTwo.findOne({ return self.RestaurantTwo.findOne({
where: {foo: 'two'} where: {foo: 'two'}
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.foo).to.equal('two'); expect(obj.foo).to.equal('two');
restaurantId = obj.id; restaurantId = obj.id;
...@@ -330,13 +330,13 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -330,13 +330,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.Employee.schema(SCHEMA_TWO), as: 'employees' model: self.Employee.schema(SCHEMA_TWO), as: 'employees'
}] }]
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.employees).to.not.be.null; expect(obj.employees).to.not.be.null;
expect(obj.employees.length).to.equal(1); expect(obj.employees.length).to.equal(1);
expect(obj.employees[0].last_name).to.equal('two'); expect(obj.employees[0].last_name).to.equal('two');
return obj.getEmployees({schema:SCHEMA_TWO}); return obj.getEmployees({schema:SCHEMA_TWO});
}).then((employees) => { }).then(employees => {
expect(employees.length).to.equal(1); expect(employees.length).to.equal(1);
expect(employees[0].last_name).to.equal('two'); expect(employees[0].last_name).to.equal('two');
return self.Employee.schema(SCHEMA_TWO).findOne({ return self.Employee.schema(SCHEMA_TWO).findOne({
...@@ -344,12 +344,12 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -344,12 +344,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.RestaurantTwo, as: 'restaurant' model: self.RestaurantTwo, as: 'restaurant'
}] }]
}); });
}).then((obj) => { }).then(obj => {
expect(obj).to.not.be.null; expect(obj).to.not.be.null;
expect(obj.restaurant).to.not.be.null; expect(obj.restaurant).to.not.be.null;
expect(obj.restaurant.foo).to.equal('two'); expect(obj.restaurant.foo).to.equal('two');
return obj.getRestaurant({schema:SCHEMA_TWO}); return obj.getRestaurant({schema:SCHEMA_TWO});
}).then((restaurant) => { }).then(restaurant => {
expect(restaurant).to.not.be.null; expect(restaurant).to.not.be.null;
expect(restaurant.foo).to.equal('two'); expect(restaurant.foo).to.equal('two');
}); });
...@@ -371,17 +371,17 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -371,17 +371,17 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return restaurauntModelSchema1.save(); return restaurauntModelSchema1.save();
}).then(() => { }).then(() => {
return Restaurant.schema(SCHEMA_ONE).findAll(); return Restaurant.schema(SCHEMA_ONE).findAll();
}).then((restaurantsOne) => { }).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null; expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(2); expect(restaurantsOne.length).to.equal(2);
restaurantsOne.forEach((restaurant) => { restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one'); expect(restaurant.bar).to.contain('one');
}); });
return Restaurant.schema(SCHEMA_TWO).findAll(); return Restaurant.schema(SCHEMA_TWO).findAll();
}).then((restaurantsTwo) => { }).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null; expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(1); expect(restaurantsTwo.length).to.equal(1);
restaurantsTwo.forEach((restaurant) => { restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two'); expect(restaurant.bar).to.contain('two');
}); });
}); });
......
...@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to merge attributes as array', function() { it('should be able to merge attributes as array', function() {
return this.ScopeMe.scope('lowAccess', 'withName').findOne() return this.ScopeMe.scope('lowAccess', 'withName').findOne()
.then((record) => { .then(record => {
expect(record.other_value).to.exist; expect(record.other_value).to.exist;
expect(record.username).to.exist; expect(record.username).to.exist;
expect(record.access_level).to.exist; expect(record.access_level).to.exist;
......
...@@ -60,7 +60,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -60,7 +60,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.ScopeMe.bulkCreate(records); return this.ScopeMe.bulkCreate(records);
}).then(() => { }).then(() => {
return this.ScopeMe.findAll(); return this.ScopeMe.findAll();
}).then((records) => { }).then(records => {
return Promise.all([ return Promise.all([
records[0].createChild({ records[0].createChild({
priority: 1 priority: 1
......
...@@ -126,7 +126,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -126,7 +126,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply default scope when including an associations', function() { it('should apply default scope when including an associations', function() {
return this.Company.findAll({ return this.Company.findAll({
include: [this.UserAssociation] include: [this.UserAssociation]
}).get(0).then((company) => { }).get(0).then(company => {
expect(company.users).to.have.length(2); expect(company.users).to.have.length(2);
}); });
}); });
...@@ -134,7 +134,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -134,7 +134,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply default scope when including a model', function() { it('should apply default scope when including a model', function() {
return this.Company.findAll({ return this.Company.findAll({
include: [{ model: this.ScopeMe, as: 'users'}] include: [{ model: this.ScopeMe, as: 'users'}]
}).get(0).then((company) => { }).get(0).then(company => {
expect(company.users).to.have.length(2); expect(company.users).to.have.length(2);
}); });
}); });
...@@ -142,7 +142,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -142,7 +142,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to include a scoped model', function() { it('should be able to include a scoped model', function() {
return this.Company.findAll({ return this.Company.findAll({
include: [{ model: this.ScopeMe.scope('isTony'), as: 'users'}] include: [{ model: this.ScopeMe.scope('isTony'), as: 'users'}]
}).get(0).then((company) => { }).get(0).then(company => {
expect(company.users).to.have.length(1); expect(company.users).to.have.length(1);
expect(company.users[0].get('username')).to.equal('tony'); expect(company.users[0].get('username')).to.equal('tony');
}); });
...@@ -161,9 +161,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -161,9 +161,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should be able to unscope', () => { describe('it should be able to unscope', () => {
it('hasMany', function() { it('hasMany', function() {
return this.Company.findById(1).then((company) => { return this.Company.findById(1).then(company => {
return company.getUsers({ scope: false}); return company.getUsers({ scope: false});
}).then((users) => { }).then(users => {
expect(users).to.have.length(4); expect(users).to.have.length(4);
}); });
}); });
...@@ -174,25 +174,25 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -174,25 +174,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1 userId: 1
}).bind(this).then(function() { }).bind(this).then(function() {
return this.ScopeMe.findById(1); return this.ScopeMe.findById(1);
}).then((user) => { }).then(user => {
return user.getProfile({ scope: false }); return user.getProfile({ scope: false });
}).then((profile) => { }).then(profile => {
expect(profile).to.be.ok; expect(profile).to.be.ok;
}); });
}); });
it('belongsTo', function() { it('belongsTo', function() {
return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then((user) => { return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then(user => {
return user.getCompany({ scope: false }); return user.getCompany({ scope: false });
}).then((company) => { }).then(company => {
expect(company).to.be.ok; expect(company).to.be.ok;
}); });
}); });
it('belongsToMany', function() { it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => { return this.Project.findAll().get(0).then(p => {
return p.getCompanies({ scope: false}); return p.getCompanies({ scope: false});
}).then((companies) => { }).then(companies => {
expect(companies).to.have.length(2); expect(companies).to.have.length(2);
}); });
}); });
...@@ -200,9 +200,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -200,9 +200,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should apply default scope', () => { describe('it should apply default scope', () => {
it('hasMany', function() { it('hasMany', function() {
return this.Company.findById(1).then((company) => { return this.Company.findById(1).then(company => {
return company.getUsers(); return company.getUsers();
}).then((users) => { }).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
}); });
}); });
...@@ -213,25 +213,25 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -213,25 +213,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1 userId: 1
}).bind(this).then(function() { }).bind(this).then(function() {
return this.ScopeMe.findById(1); return this.ScopeMe.findById(1);
}).then((user) => { }).then(user => {
return user.getProfile(); return user.getProfile();
}).then((profile) => { }).then(profile => {
expect(profile).not.to.be.ok; expect(profile).not.to.be.ok;
}); });
}); });
it('belongsTo', function() { it('belongsTo', function() {
return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then((user) => { return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then(user => {
return user.getCompany(); return user.getCompany();
}).then((company) => { }).then(company => {
expect(company).not.to.be.ok; expect(company).not.to.be.ok;
}); });
}); });
it('belongsToMany', function() { it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => { return this.Project.findAll().get(0).then(p => {
return p.getCompanies(); return p.getCompanies();
}).then((companies) => { }).then(companies => {
expect(companies).to.have.length(1); expect(companies).to.have.length(1);
expect(companies[0].get('active')).to.be.ok; expect(companies[0].get('active')).to.be.ok;
}); });
...@@ -240,9 +240,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -240,9 +240,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should be able to apply another scope', () => { describe('it should be able to apply another scope', () => {
it('hasMany', function() { it('hasMany', function() {
return this.Company.findById(1).then((company) => { return this.Company.findById(1).then(company => {
return company.getUsers({ scope: 'isTony'}); return company.getUsers({ scope: 'isTony'});
}).then((users) => { }).then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].get('username')).to.equal('tony'); expect(users[0].get('username')).to.equal('tony');
}); });
...@@ -254,25 +254,25 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -254,25 +254,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1 userId: 1
}).bind(this).then(function() { }).bind(this).then(function() {
return this.ScopeMe.findById(1); return this.ScopeMe.findById(1);
}).then((user) => { }).then(user => {
return user.getProfile({ scope: 'notActive' }); return user.getProfile({ scope: 'notActive' });
}).then((profile) => { }).then(profile => {
expect(profile).not.to.be.ok; expect(profile).not.to.be.ok;
}); });
}); });
it('belongsTo', function() { it('belongsTo', function() {
return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then((user) => { return this.ScopeMe.unscoped().find({ where: { username: 'bob' }}).then(user => {
return user.getCompany({ scope: 'notActive' }); return user.getCompany({ scope: 'notActive' });
}).then((company) => { }).then(company => {
expect(company).to.be.ok; expect(company).to.be.ok;
}); });
}); });
it('belongsToMany', function() { it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => { return this.Project.findAll().get(0).then(p => {
return p.getCompanies({ scope: 'reversed' }); return p.getCompanies({ scope: 'reversed' });
}).then((companies) => { }).then(companies => {
expect(companies).to.have.length(2); expect(companies).to.have.length(2);
expect(companies[0].id).to.equal(2); expect(companies[0].id).to.equal(2);
expect(companies[1].id).to.equal(1); expect(companies[1].id).to.equal(1);
...@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should apply scope conditions', function() { it('should apply scope conditions', function() {
return this.ScopeMe.scope('includeActiveProjects').findOne({ where: { id: 1 }}).then((user) => { return this.ScopeMe.scope('includeActiveProjects').findOne({ where: { id: 1 }}).then(user => {
expect(user.company.projects).to.have.length(1); expect(user.company.projects).to.have.length(1);
}); });
}); });
......
...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.ScopeMe.bulkCreate(records); return this.ScopeMe.bulkCreate(records);
}).then(() => { }).then(() => {
return this.ScopeMe.findAll(); return this.ScopeMe.findAll();
}).then((records) => { }).then(records => {
return Promise.all([ return Promise.all([
records[0].createChild({ records[0].createChild({
priority: 1 priority: 1
......
...@@ -47,7 +47,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -47,7 +47,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply defaultScope', function() { it('should apply defaultScope', function() {
return this.ScopeMe.destroy({ where: {}}).bind(this).then(function() { return this.ScopeMe.destroy({ where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll(); return this.ScopeMe.unscoped().findAll();
}).then((users) => { }).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect(users[0].get('username')).to.equal('tony'); expect(users[0].get('username')).to.equal('tony');
expect(users[1].get('username')).to.equal('fred'); expect(users[1].get('username')).to.equal('fred');
...@@ -57,7 +57,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -57,7 +57,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to override default scope', function() { it('should be able to override default scope', function() {
return this.ScopeMe.destroy({ where: { access_level: { lt: 5 }}}).bind(this).then(function() { return this.ScopeMe.destroy({ where: { access_level: { lt: 5 }}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll(); return this.ScopeMe.unscoped().findAll();
}).then((users) => { }).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect(users[0].get('username')).to.equal('tobi'); expect(users[0].get('username')).to.equal('tobi');
expect(users[1].get('username')).to.equal('dan'); expect(users[1].get('username')).to.equal('dan');
...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to apply other scopes', function() { it('should be able to apply other scopes', function() {
return this.ScopeMe.scope('lowAccess').destroy({ where: {}}).bind(this).then(function() { return this.ScopeMe.scope('lowAccess').destroy({ where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll(); return this.ScopeMe.unscoped().findAll();
}).then((users) => { }).then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].get('username')).to.equal('tobi'); expect(users[0].get('username')).to.equal('tobi');
}); });
...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to merge scopes with where', function() { it('should be able to merge scopes with where', function() {
return this.ScopeMe.scope('lowAccess').destroy({ where: { username: 'dan'}}).bind(this).then(function() { return this.ScopeMe.scope('lowAccess').destroy({ where: { username: 'dan'}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll(); return this.ScopeMe.unscoped().findAll();
}).then((users) => { }).then(users => {
expect(users).to.have.length(3); expect(users).to.have.length(3);
expect(users[0].get('username')).to.equal('tony'); expect(users[0].get('username')).to.equal('tony');
expect(users[1].get('username')).to.equal('tobi'); expect(users[1].get('username')).to.equal('tobi');
......
...@@ -57,14 +57,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -57,14 +57,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be able use where in scope', function() { it('should be able use where in scope', function() {
return this.ScopeMe.scope({where: { parent_id: 2 }}).findAll().then((users) => { return this.ScopeMe.scope({where: { parent_id: 2 }}).findAll().then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].username).to.equal('tobi'); expect(users[0].username).to.equal('tobi');
}); });
}); });
it('should be able to combine scope and findAll where clauses', function() { it('should be able to combine scope and findAll where clauses', function() {
return this.ScopeMe.scope({where: { parent_id: 1 }}).findAll({ where: {access_level: 3}}).then((users) => { return this.ScopeMe.scope({where: { parent_id: 1 }}).findAll({ where: {access_level: 3}}).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect(['tony', 'fred'].indexOf(users[0].username) !== -1).to.be.true; expect(['tony', 'fred'].indexOf(users[0].username) !== -1).to.be.true;
expect(['tony', 'fred'].indexOf(users[1].username) !== -1).to.be.true; expect(['tony', 'fred'].indexOf(users[1].username) !== -1).to.be.true;
...@@ -72,7 +72,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -72,7 +72,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be able to use a defaultScope if declared', function() { it('should be able to use a defaultScope if declared', function() {
return this.ScopeMe.all().then((users) => { return this.ScopeMe.all().then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect([10, 5].indexOf(users[0].access_level) !== -1).to.be.true; expect([10, 5].indexOf(users[0].access_level) !== -1).to.be.true;
expect([10, 5].indexOf(users[1].access_level) !== -1).to.be.true; expect([10, 5].indexOf(users[1].access_level) !== -1).to.be.true;
...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should be able to handle $and in scopes', function() { it('should be able to handle $and in scopes', function() {
return this.ScopeMe.scope('andScope').findAll().then((users) => { return this.ScopeMe.scope('andScope').findAll().then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].username).to.equal('tony'); expect(users[0].username).to.equal('tony');
}); });
...@@ -94,7 +94,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -94,7 +94,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
return this.ScopeMe.findAll(); return this.ScopeMe.findAll();
}).then((users) => { }).then(users => {
// This should not have other_value: 10 // This should not have other_value: 10
expect(users).to.have.length(2); expect(users).to.have.length(2);
}); });
...@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
return this.ScopeMe.scope('highValue').findAll(); return this.ScopeMe.scope('highValue').findAll();
}).then((users) => { }).then(users => {
// This should not have other_value: 10 // This should not have other_value: 10
expect(users).to.have.length(2); expect(users).to.have.length(2);
}); });
...@@ -114,7 +114,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -114,7 +114,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should have no problem performing findOrCreate', function() { it('should have no problem performing findOrCreate', function() {
return this.ScopeMe.findOrCreate({ where: {username: 'fake'}}).spread((user) => { return this.ScopeMe.findOrCreate({ where: {username: 'fake'}}).spread(user => {
expect(user.username).to.equal('fake'); expect(user.username).to.equal('fake');
}); });
}); });
......
...@@ -51,7 +51,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -51,7 +51,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}); });
it('should apply defaultScope', function() { it('should apply defaultScope', function() {
return this.ScopeMe.findAndCount().then((result) => { return this.ScopeMe.findAndCount().then(result => {
expect(result.count).to.equal(2); expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(2); expect(result.rows.length).to.equal(2);
}); });
...@@ -59,7 +59,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -59,7 +59,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to override default scope', function() { it('should be able to override default scope', function() {
return this.ScopeMe.findAndCount({ where: { access_level: { gt: 5 }}}) return this.ScopeMe.findAndCount({ where: { access_level: { gt: 5 }}})
.then((result) => { .then(result => {
expect(result.count).to.equal(1); expect(result.count).to.equal(1);
expect(result.rows.length).to.equal(1); expect(result.rows.length).to.equal(1);
}); });
...@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to unscope', function() { it('should be able to unscope', function() {
return this.ScopeMe.unscoped().findAndCount({ limit: 1 }) return this.ScopeMe.unscoped().findAndCount({ limit: 1 })
.then((result) => { .then(result => {
expect(result.count).to.equal(4); expect(result.count).to.equal(4);
expect(result.rows.length).to.equal(1); expect(result.rows.length).to.equal(1);
}); });
...@@ -75,21 +75,21 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -75,21 +75,21 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to apply other scopes', function() { it('should be able to apply other scopes', function() {
return this.ScopeMe.scope('lowAccess').findAndCount() return this.ScopeMe.scope('lowAccess').findAndCount()
.then((result) => { .then(result => {
expect(result.count).to.equal(3); expect(result.count).to.equal(3);
}); });
}); });
it('should be able to merge scopes with where', function() { it('should be able to merge scopes with where', function() {
return this.ScopeMe.scope('lowAccess') return this.ScopeMe.scope('lowAccess')
.findAndCount({ where: { username: 'dan'}}).then((result) => { .findAndCount({ where: { username: 'dan'}}).then(result => {
expect(result.count).to.equal(1); expect(result.count).to.equal(1);
}); });
}); });
it('should ignore the order option if it is found within the scope', function() { it('should ignore the order option if it is found within the scope', function() {
return this.ScopeMe.scope('withOrder').findAndCount() return this.ScopeMe.scope('withOrder').findAndCount()
.then((result) => { .then(result => {
expect(result.count).to.equal(4); expect(result.count).to.equal(4);
}); });
}); });
......
...@@ -48,7 +48,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -48,7 +48,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply defaultScope', function() { it('should apply defaultScope', function() {
return this.ScopeMe.update({ username: 'ruben' }, { where: {}}).bind(this).then(function() { return this.ScopeMe.update({ username: 'ruben' }, { where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }}); return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => { }).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect(users[0].get('email')).to.equal('tobi@fakeemail.com'); expect(users[0].get('email')).to.equal('tobi@fakeemail.com');
expect(users[1].get('email')).to.equal('dan@sequelizejs.com'); expect(users[1].get('email')).to.equal('dan@sequelizejs.com');
...@@ -58,7 +58,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -58,7 +58,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to override default scope', function() { it('should be able to override default scope', function() {
return this.ScopeMe.update({ username: 'ruben' }, { where: { access_level: { lt: 5 }}}).bind(this).then(function() { return this.ScopeMe.update({ username: 'ruben' }, { where: { access_level: { lt: 5 }}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }}); return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => { }).then(users => {
expect(users).to.have.length(2); expect(users).to.have.length(2);
expect(users[0].get('email')).to.equal('tony@sequelizejs.com'); expect(users[0].get('email')).to.equal('tony@sequelizejs.com');
expect(users[1].get('email')).to.equal('fred@foobar.com'); expect(users[1].get('email')).to.equal('fred@foobar.com');
...@@ -68,8 +68,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -68,8 +68,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to unscope destroy', function() { it('should be able to unscope destroy', function() {
return this.ScopeMe.unscoped().update({ username: 'ruben' }, { where: {}}).bind(this).then(function() { return this.ScopeMe.unscoped().update({ username: 'ruben' }, { where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll(); return this.ScopeMe.unscoped().findAll();
}).then((rubens) => { }).then(rubens => {
expect(_.every(rubens, (r) => { expect(_.every(rubens, r => {
return r.get('username') === 'ruben'; return r.get('username') === 'ruben';
})).to.be.true; })).to.be.true;
}); });
...@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to apply other scopes', function() { it('should be able to apply other scopes', function() {
return this.ScopeMe.scope('lowAccess').update({ username: 'ruben' }, { where: {}}).bind(this).then(function() { return this.ScopeMe.scope('lowAccess').update({ username: 'ruben' }, { where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll({ where: { username: { $ne: 'ruben' }}}); return this.ScopeMe.unscoped().findAll({ where: { username: { $ne: 'ruben' }}});
}).then((users) => { }).then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].get('email')).to.equal('tobi@fakeemail.com'); expect(users[0].get('email')).to.equal('tobi@fakeemail.com');
}); });
...@@ -87,7 +87,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -87,7 +87,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to merge scopes with where', function() { it('should be able to merge scopes with where', function() {
return this.ScopeMe.scope('lowAccess').update({ username: 'ruben' }, { where: { username: 'dan'}}).bind(this).then(function() { return this.ScopeMe.scope('lowAccess').update({ username: 'ruben' }, { where: { username: 'dan'}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }}); return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => { }).then(users => {
expect(users).to.have.length(1); expect(users).to.have.length(1);
expect(users[0].get('email')).to.equal('dan@sequelizejs.com'); expect(users[0].get('email')).to.equal('dan@sequelizejs.com');
}); });
......
...@@ -74,7 +74,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -74,7 +74,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
expect(user.createdAt).to.be.ok; expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe'); expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt); expect(user.updatedAt).to.be.afterTime(user.createdAt);
...@@ -99,7 +99,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -99,7 +99,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return this.User.find({ where: { foo: 'baz', bar: 19 }}); return this.User.find({ where: { foo: 'baz', bar: 19 }});
}).then((user) => { }).then(user => {
expect(user.createdAt).to.be.ok; expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe'); expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt); expect(user.updatedAt).to.be.afterTime(user.createdAt);
...@@ -158,7 +158,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -158,7 +158,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this.clock.tick(1000); this.clock.tick(1000);
// Update the first one // Update the first one
return User.upsert({ a: 'a', b: 'b', username: 'doe' }); return User.upsert({ a: 'a', b: 'b', username: 'doe' });
}).then((created) => { }).then(created => {
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
expect(created).to.be.undefined; expect(created).to.be.undefined;
} else { } else {
...@@ -166,13 +166,13 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -166,13 +166,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return User.find({ where: { a: 'a', b: 'b' }}); return User.find({ where: { a: 'a', b: 'b' }});
}).then((user1) => { }).then(user1 => {
expect(user1.createdAt).to.be.ok; expect(user1.createdAt).to.be.ok;
expect(user1.username).to.equal('doe'); expect(user1.username).to.equal('doe');
expect(user1.updatedAt).to.be.afterTime(user1.createdAt); expect(user1.updatedAt).to.be.afterTime(user1.createdAt);
return User.find({ where: { a: 'a', b: 'a' }}); return User.find({ where: { a: 'a', b: 'a' }});
}).then((user2) => { }).then(user2 => {
// The second one should not be updated // The second one should not be updated
expect(user2.createdAt).to.be.ok; expect(user2.createdAt).to.be.ok;
expect(user2.username).to.equal('curt'); expect(user2.username).to.equal('curt');
...@@ -212,7 +212,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -212,7 +212,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
expect(user.createdAt).to.be.ok; expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe'); expect(user.username).to.equal('doe');
expect(user.blob.toString()).to.equal('andrea'); expect(user.blob.toString()).to.equal('andrea');
...@@ -237,7 +237,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -237,7 +237,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
expect(user.baz).to.equal('oof'); expect(user.baz).to.equal('oof');
}); });
}); });
...@@ -261,7 +261,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -261,7 +261,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
return this.ModelWithFieldPK.findOne({ where: { userId: 42 } }); return this.ModelWithFieldPK.findOne({ where: { userId: 42 } });
}).then((instance) => { }).then(instance => {
expect(instance.foo).to.equal('second'); expect(instance.foo).to.equal('second');
}); });
}); });
...@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(created).not.to.be.ok; expect(created).not.to.be.ok;
} }
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
expect(user.createdAt).to.be.ok; expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe'); expect(user.username).to.equal('doe');
expect(user.foo).to.equal('MIXEDCASE2'); expect(user.foo).to.equal('MIXEDCASE2');
...@@ -304,7 +304,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -304,7 +304,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.upsert({ id: 42, username: 'doe'}); return this.User.upsert({ id: 42, username: 'doe'});
}).then(function() { }).then(function() {
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
expect(user.updatedAt).to.be.gt(originalUpdatedAt); expect(user.updatedAt).to.be.gt(originalUpdatedAt);
expect(user.createdAt).to.deep.equal(originalCreatedAt); expect(user.createdAt).to.deep.equal(originalCreatedAt);
clock.restore(); clock.restore();
...@@ -322,7 +322,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -322,7 +322,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.upsert({ id: 42, username: 'doe'}); return this.User.upsert({ id: 42, username: 'doe'});
}).then(function() { }).then(function() {
return this.User.findById(42); return this.User.findById(42);
}).then((user) => { }).then(user => {
// 'username' was updated // 'username' was updated
expect(user.username).to.equal('doe'); expect(user.username).to.equal('doe');
// 'baz' should still be 'new baz value' since it was not updated // 'baz' should still be 'new baz value' since it was not updated
...@@ -335,7 +335,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -335,7 +335,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.findById(42); return this.User.findById(42);
}).then(function(user) { }).then(function(user) {
return this.User.upsert({ id: user.id, username: user.username }); return this.User.upsert({ id: user.id, username: user.username });
}).then((created) => { }).then(created => {
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
expect(created).to.be.undefined; expect(created).to.be.undefined;
} else { } else {
...@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const clock = sinon.useFakeTimers(); const clock = sinon.useFakeTimers();
return User.sync({ force: true }).bind(this).then(() => { return User.sync({ force: true }).bind(this).then(() => {
return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'City' }) return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'City' })
.then((created) => { .then(created => {
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
expect(created).to.be.undefined; expect(created).to.be.undefined;
} else { } else {
...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
} }
clock.tick(1000); clock.tick(1000);
return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'New City' }); return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'New City' });
}).then((created) => { }).then(created => {
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
expect(created).to.be.undefined; expect(created).to.be.undefined;
} else { } else {
...@@ -381,7 +381,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { ...@@ -381,7 +381,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
clock.tick(1000); clock.tick(1000);
return User.findOne({ where: { username: 'user1', email: 'user1@domain.ext' }}); return User.findOne({ where: { username: 'user1', email: 'user1@domain.ext' }});
}) })
.then((user) => { .then(user => {
expect(user.createdAt).to.be.ok; expect(user.createdAt).to.be.ok;
expect(user.city).to.equal('New City'); expect(user.city).to.equal('New City');
expect(user.updatedAt).to.be.afterTime(user.createdAt); expect(user.updatedAt).to.be.afterTime(user.createdAt);
......
...@@ -67,14 +67,14 @@ describe(Support.getTestDialectTeaser('Replication'), function() { ...@@ -67,14 +67,14 @@ describe(Support.getTestDialectTeaser('Replication'), function() {
}); });
it('should run read-only transactions on the replica', () => { it('should run read-only transactions on the replica', () => {
return this.sequelize.transaction({readOnly: true}, (transaction) => { return this.sequelize.transaction({readOnly: true}, transaction => {
return this.User.findAll({transaction}); return this.User.findAll({transaction});
}) })
.then(expectReadCalls); .then(expectReadCalls);
}); });
it('should run non-read-only transactions on the primary', () => { it('should run non-read-only transactions on the primary', () => {
return this.sequelize.transaction((transaction) => { return this.sequelize.transaction(transaction => {
return this.User.findAll({transaction}); return this.User.findAll({transaction});
}) })
.then(expectWriteCalls); .then(expectWriteCalls);
......
...@@ -25,22 +25,22 @@ describe(Support.getTestDialectTeaser('Schema'), () => { ...@@ -25,22 +25,22 @@ describe(Support.getTestDialectTeaser('Schema'), () => {
}); });
it('supports increment', function() { it('supports increment', function() {
return this.User.create({ aNumber: 1 }).then((user) => { return this.User.create({ aNumber: 1 }).then(user => {
return user.increment('aNumber', { by: 3 }); return user.increment('aNumber', { by: 3 });
}).then((result) => { }).then(result => {
return result.reload(); return result.reload();
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(4); expect(user.aNumber).to.be.equal(4);
}); });
}); });
it('supports decrement', function() { it('supports decrement', function() {
return this.User.create({ aNumber: 10 }).then((user) => { return this.User.create({ aNumber: 10 }).then(user => {
return user.decrement('aNumber', { by: 3 }); return user.decrement('aNumber', { by: 3 });
}).then((result) => { }).then(result => {
return result.reload(); return result.reload();
}).then((user) => { }).then(user => {
expect(user).to.be.ok; expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(7); expect(user.aNumber).to.be.equal(7);
}); });
......
...@@ -24,7 +24,7 @@ if (current.dialect.supports.transactions) { ...@@ -24,7 +24,7 @@ if (current.dialect.supports.transactions) {
let called = false; let called = false;
return this return this
.sequelize .sequelize
.transaction().then((t) => { .transaction().then(t => {
return t.commit().then(() => { return t.commit().then(() => {
called = 1; called = 1;
}); });
...@@ -38,7 +38,7 @@ if (current.dialect.supports.transactions) { ...@@ -38,7 +38,7 @@ if (current.dialect.supports.transactions) {
let called = false; let called = false;
return this return this
.sequelize .sequelize
.transaction().then((t) => { .transaction().then(t => {
return t.rollback().then(() => { return t.rollback().then(() => {
called = 1; called = 1;
}); });
...@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) { ...@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) {
}); });
}).then(function() { }).then(function() {
return this.User.all(); return this.User.all();
}).then((users) => { }).then(users => {
expect(users.length).to.equal(1); expect(users.length).to.equal(1);
expect(users[0].name).to.equal('foo'); expect(users[0].name).to.equal('foo');
}); });
...@@ -96,14 +96,14 @@ if (current.dialect.supports.transactions) { ...@@ -96,14 +96,14 @@ if (current.dialect.supports.transactions) {
describe('complex long running example', () => { describe('complex long running example', () => {
it('works with promise syntax', function() { it('works with promise syntax', function() {
return Support.prepareTransactionTest(this.sequelize).then((sequelize) => { return Support.prepareTransactionTest(this.sequelize).then(sequelize => {
const Test = sequelize.define('Test', { const Test = sequelize.define('Test', {
id: { type: Support.Sequelize.INTEGER, primaryKey: true, autoIncrement: true}, id: { type: Support.Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
name: { type: Support.Sequelize.STRING } name: { type: Support.Sequelize.STRING }
}); });
return sequelize.sync({ force: true }).then(() => { return sequelize.sync({ force: true }).then(() => {
return sequelize.transaction().then((transaction) => { return sequelize.transaction().then(transaction => {
expect(transaction).to.be.instanceOf(Transaction); expect(transaction).to.be.instanceOf(Transaction);
return Test return Test
...@@ -113,7 +113,7 @@ if (current.dialect.supports.transactions) { ...@@ -113,7 +113,7 @@ if (current.dialect.supports.transactions) {
return transaction return transaction
.commit() .commit()
.then(() => { return Test.count(); }) .then(() => { return Test.count(); })
.then((count) => { .then(count => {
expect(count).to.equal(1); expect(count).to.equal(1);
}); });
}); });
...@@ -129,7 +129,7 @@ if (current.dialect.supports.transactions) { ...@@ -129,7 +129,7 @@ if (current.dialect.supports.transactions) {
beforeEach(function() { beforeEach(function() {
const self = this; const self = this;
return Support.prepareTransactionTest(this.sequelize).then((sequelize) => { return Support.prepareTransactionTest(this.sequelize).then(sequelize => {
self.sequelize = sequelize; self.sequelize = sequelize;
self.Model = sequelize.define('Model', { self.Model = sequelize.define('Model', {
...@@ -145,11 +145,11 @@ if (current.dialect.supports.transactions) { ...@@ -145,11 +145,11 @@ if (current.dialect.supports.transactions) {
it('triggers the error event for the second transactions', function() { it('triggers the error event for the second transactions', function() {
const self = this; const self = this;
return this.sequelize.transaction().then((t1) => { return this.sequelize.transaction().then(t1 => {
return self.sequelize.transaction().then((t2) => { return self.sequelize.transaction().then(t2 => {
return self.Model.create({ name: 'omnom' }, { transaction: t1 }).then(() => { return self.Model.create({ name: 'omnom' }, { transaction: t1 }).then(() => {
return Promise.all([ return Promise.all([
self.Model.create({ name: 'omnom' }, { transaction: t2 }).catch((err) => { self.Model.create({ name: 'omnom' }, { transaction: t2 }).catch(err => {
expect(err).to.be.ok; expect(err).to.be.ok;
return t2.rollback(); return t2.rollback();
}), }),
......
...@@ -46,10 +46,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -46,10 +46,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
return User.sync({ force: true }).bind(this).then(() => { return User.sync({ force: true }).bind(this).then(() => {
return Task.sync({ force: true }); return Task.sync({ force: true });
}).then(function() { }).then(function() {
return this.sequelize.transaction(transactionOptions, (t) => { return this.sequelize.transaction(transactionOptions, t => {
return Task return Task
.create({ title: 'a task', user_id: -1 }, { transaction: t }) .create({ title: 'a task', user_id: -1 }, { transaction: t })
.then((task) => { .then(task => {
return [task, User.create({}, { transaction: t })]; return [task, User.create({}, { transaction: t })];
}) })
.spread((task, user) => { .spread((task, user) => {
...@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('allows the violation of the foreign key constraint if the transaction is deferred', function() { it('allows the violation of the foreign key constraint if the transaction is deferred', function() {
return this return this
.run(Sequelize.Deferrable.INITIALLY_IMMEDIATE) .run(Sequelize.Deferrable.INITIALLY_IMMEDIATE)
.then((task) => { .then(task => {
expect(task.title).to.equal('a task'); expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1); expect(task.user_id).to.equal(1);
}); });
...@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
deferrable: Sequelize.Deferrable.SET_DEFERRED([taskTableName + '_user_id_fkey']), deferrable: Sequelize.Deferrable.SET_DEFERRED([taskTableName + '_user_id_fkey']),
taskTableName taskTableName
}) })
.then((task) => { .then(task => {
expect(task.title).to.equal('a task'); expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1); expect(task.user_id).to.equal(1);
}); });
...@@ -102,7 +102,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -102,7 +102,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('allows the violation of the foreign key constraint', function() { it('allows the violation of the foreign key constraint', function() {
return this return this
.run(Sequelize.Deferrable.INITIALLY_DEFERRED) .run(Sequelize.Deferrable.INITIALLY_DEFERRED)
.then((task) => { .then(task => {
expect(task.title).to.equal('a task'); expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1); expect(task.user_id).to.equal(1);
}); });
......
...@@ -62,7 +62,7 @@ if (dialect !== 'sqlite') { ...@@ -62,7 +62,7 @@ if (dialect !== 'sqlite') {
return this.sequelize.sync({ force: true }).bind(this).then(() => { return this.sequelize.sync({ force: true }).bind(this).then(() => {
return TimezonedUser.create({}); return TimezonedUser.create({});
}).then((timezonedUser) => { }).then(timezonedUser => {
return Promise.all([ return Promise.all([
NormalUser.findById(timezonedUser.id), NormalUser.findById(timezonedUser.id),
TimezonedUser.findById(timezonedUser.id) TimezonedUser.findById(timezonedUser.id)
......
...@@ -48,7 +48,7 @@ if (current.dialect.supports.tmpTableTrigger) { ...@@ -48,7 +48,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should return output rows after instance update', () => { it('should return output rows after instance update', () => {
return User.create({ return User.create({
username: 'triggertest' username: 'triggertest'
}).then((user) => { }).then(user => {
user.username = 'usernamechanged'; user.username = 'usernamechanged';
return user.save(); return user.save();
}) })
...@@ -60,7 +60,7 @@ if (current.dialect.supports.tmpTableTrigger) { ...@@ -60,7 +60,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should return output rows after Model update', () => { it('should return output rows after Model update', () => {
return User.create({ return User.create({
username: 'triggertest' username: 'triggertest'
}).then((user) => { }).then(user => {
return User.update({ return User.update({
username: 'usernamechanged' username: 'usernamechanged'
}, { }, {
...@@ -77,7 +77,7 @@ if (current.dialect.supports.tmpTableTrigger) { ...@@ -77,7 +77,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should successfully delete with a trigger on the table', () => { it('should successfully delete with a trigger on the table', () => {
return User.create({ return User.create({
username: 'triggertest' username: 'triggertest'
}).then((user) => { }).then(user => {
return user.destroy(); return user.destroy();
}).then(() => { }).then(() => {
return expect(User.find({username: 'triggertest'})).to.eventually.be.null; return expect(User.find({username: 'triggertest'})).to.eventually.be.null;
......
...@@ -271,7 +271,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => { ...@@ -271,7 +271,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
} }
}, type)), 'count-engines-wings'] }, type)), 'count-engines-wings']
] ]
}).spread((airplane) => { }).spread(airplane => {
expect(parseInt(airplane.get('count'))).to.equal(3); expect(parseInt(airplane.get('count'))).to.equal(3);
expect(parseInt(airplane.get('count-engines'))).to.equal(1); expect(parseInt(airplane.get('count-engines'))).to.equal(1);
expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2); expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2);
...@@ -296,7 +296,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => { ...@@ -296,7 +296,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
} }
}), 'count-engines-wings'] }), 'count-engines-wings']
] ]
}).spread((airplane) => { }).spread(airplane => {
expect(parseInt(airplane.get('count'))).to.equal(3); expect(parseInt(airplane.get('count'))).to.equal(3);
expect(parseInt(airplane.get('count-engines'))).to.equal(1); expect(parseInt(airplane.get('count-engines'))).to.equal(1);
expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2); expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2);
......
...@@ -18,10 +18,10 @@ describe(Support.getTestDialectTeaser('Vectors'), () => { ...@@ -18,10 +18,10 @@ describe(Support.getTestDialectTeaser('Vectors'), () => {
return Student.sync({force: true}).then(() => { return Student.sync({force: true}).then(() => {
return Student.create({ return Student.create({
name: 'Robert\\\'); DROP TABLE "students"; --' name: 'Robert\\\'); DROP TABLE "students"; --'
}).then((result) => { }).then(result => {
expect(result.get('name')).to.equal('Robert\\\'); DROP TABLE "students"; --'); expect(result.get('name')).to.equal('Robert\\\'); DROP TABLE "students"; --');
return Student.findAll(); return Student.findAll();
}).then((result) => { }).then(result => {
expect(result[0].name).to.equal('Robert\\\'); DROP TABLE "students"; --'); expect(result[0].name).to.equal('Robert\\\'); DROP TABLE "students"; --');
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!