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

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 @@
"space-before-function-paren": ["warn", "never"],
"keyword-spacing": ["warn"],
"prefer-arrow-callback": "error",
"arrow-parens": ["error", "as-needed"],
"comma-style": ["warn", "last"],
"no-bitwise": "off",
"no-cond-assign": ["error", "except-parens"],
......
......@@ -113,7 +113,7 @@ SET_IMMEDIATE.prototype.toSql = function(queryGenerator) {
return queryGenerator.setImmediateQuery(this.constraints);
};
Object.keys(Deferrable).forEach((key) => {
Object.keys(Deferrable).forEach(key => {
const DeferrableType = Deferrable[key];
DeferrableType.toString = function() {
......
......@@ -45,7 +45,7 @@ class ConnectionManager {
}
refreshTypeParser(dataTypes) {
_.each(dataTypes, (dataType) => {
_.each(dataTypes, dataType => {
if (dataType.hasOwnProperty('parse')) {
if (dataType.types[this.dialectName]) {
this._refreshTypeParser(dataType);
......@@ -84,7 +84,7 @@ class ConnectionManager {
if (!config.replication) {
this.pool = Pooling.createPool({
create: () => new Promise((resolve) => {
create: () => new Promise(resolve => {
this
._connect(config)
.tap(() => {
......@@ -98,7 +98,7 @@ class ConnectionManager {
this.poolError = e;
});
}),
destroy: (connection) => {
destroy: connection => {
return this._disconnect(connection).tap(() => {
debug('connection destroy');
});
......@@ -173,7 +173,7 @@ class ConnectionManager {
read: Pooling.createPool({
create: () => {
const nextRead = reads++ % config.replication.read.length; // round robin config
return new Promise((resolve) => {
return new Promise(resolve => {
this
._connect(config.replication.read[nextRead])
.tap(connection => {
......@@ -200,7 +200,7 @@ class ConnectionManager {
idleTimeoutMillis: config.pool.idle
}),
write: Pooling.createPool({
create: () => new Promise((resolve) => {
create: () => new Promise(resolve => {
this
._connect(config.replication.write)
.then(connection => {
......
......@@ -846,7 +846,7 @@ const QueryGenerator = {
}
// 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);
}, this);
......
......@@ -85,7 +85,7 @@ const QueryGenerator = {
table: this.quoteTable(tableName),
attributes: attrStr.join(', ')
},
pkString = primaryKeys.map((pk) => { return this.quoteIdentifier(pk); }).join(', ');
pkString = primaryKeys.map(pk => { return this.quoteIdentifier(pk); }).join(', ');
if (options.uniqueKeys) {
Utils._.each(options.uniqueKeys, (columns, indexName) => {
......@@ -253,7 +253,7 @@ const QueryGenerator = {
outputFragment = ' OUTPUT INSERTED.*';
}
Utils._.forEach(attrValueHashes, (attrValueHash) => {
Utils._.forEach(attrValueHashes, attrValueHash => {
// special case for empty objects with primary keys
const fields = Object.keys(attrValueHash);
const firstAttr = attributes[fields[0]];
......@@ -278,7 +278,7 @@ const QueryGenerator = {
});
if (allAttributes.length > 0) {
Utils._.forEach(attrValueHashes, (attrValueHash) => {
Utils._.forEach(attrValueHashes, attrValueHash => {
tuples.push('(' +
allAttributes.map(key =>
this.escape(attrValueHash[key])).join(',') +
......@@ -515,7 +515,7 @@ const QueryGenerator = {
// enums are a special case
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);
}).join(', ') + '))';
return template;
......
......@@ -15,7 +15,7 @@ ResourceLock.prototype.lock = function() {
const lock = this.previous;
let resolve;
this.previous = new Promise((r) => {
this.previous = new Promise(r => {
resolve = r;
});
......
......@@ -91,7 +91,7 @@ class ConnectionManager extends AbstractConnectionManager {
return new Utils.Promise((resolve, reject) => {
const connection = this.lib.createConnection(connectionConfig);
const errorHandler = (e) => {
const errorHandler = e => {
// clean up connect event if there is error
connection.removeListener('connect', connectHandler);
reject(e);
......@@ -106,7 +106,7 @@ class ConnectionManager extends AbstractConnectionManager {
connection.once('error', errorHandler);
connection.once('connect', connectHandler);
})
.then((connection) => {
.then(connection => {
if (config.pool.handleDisconnects) {
// Connection to the MySQL server is usually
......@@ -115,7 +115,7 @@ class ConnectionManager extends AbstractConnectionManager {
// server variable configures this)
//
// 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') {
// Remove it from read/write pool
this.pool.destroy(connection);
......@@ -127,19 +127,19 @@ class ConnectionManager extends AbstractConnectionManager {
debug('connection acquired');
return connection;
})
.then((connection) => {
.then(connection => {
return new Utils.Promise((resolve, reject) => {
// set timezone for this connection
// but named timezone are not directly supported in mysql, so get its offset first
let tzOffset = this.sequelize.options.timezone;
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); }
});
});
})
.catch((err) => {
.catch(err => {
if (err.code) {
switch (err.code) {
case 'ECONNREFUSED':
......@@ -170,7 +170,7 @@ class ConnectionManager extends AbstractConnectionManager {
}
return new Utils.Promise((resolve, reject) => {
connection.end((err) => {
connection.end(err => {
if (err) {
reject(new SequelizeErrors.ConnectionError(err));
} else {
......
......@@ -45,7 +45,7 @@ class ConnectionManager extends AbstractConnectionManager {
if (dataType.types.postgres.array_oids) {
for (const oid of dataType.types.postgres.array_oids) {
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)
).parse()
);
......@@ -123,7 +123,7 @@ class ConnectionManager extends AbstractConnectionManager {
});
// 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}`);
connection._invalid = true;
});
......
......@@ -195,7 +195,7 @@ class Query extends AbstractQuery {
m[k.toLowerCase()] = k;
return m;
}, {});
rows = _.map(rows, (row)=> {
rows = _.map(rows, row=> {
return _.mapKeys(row, (value, key)=> {
const targetAttr = attrsMap[key];
if (typeof targetAttr === 'string' && targetAttr !== key) {
......
......@@ -59,7 +59,7 @@ exports.hookAliases = hookAliases;
* get array of current hook and its proxied hooks combined
* @private
*/
const getProxiedHooks = (hookType) =>
const getProxiedHooks = hookType =>
hookTypes[hookType].proxies
? hookTypes[hookType].proxies.concat(hookType)
: [hookType]
......@@ -67,11 +67,10 @@ const getProxiedHooks = (hookType) =>
const Hooks = {
replaceHookAliases(hooks) {
let realHookName;
Utils._.each(hooks, (hooksArray, name) => {
// 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
hooks[realHookName] = (hooks[realHookName] || []).concat(hooksArray);
......@@ -149,7 +148,7 @@ const Hooks = {
// check for proxies, add them too
hookType = getProxiedHooks(hookType);
Utils._.each(hookType, (type) => {
Utils._.each(hookType, type => {
this.options.hooks[type] = this.options.hooks[type] || [];
this.options.hooks[type].push(name ? {name, fn} : fn);
});
......
......@@ -459,7 +459,7 @@ class Model {
if (include.attributes.length) {
_.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)
if (!_.some(include.attributes, (includeAttr) => {
if (!_.some(include.attributes, includeAttr => {
if (attr.field !== key) {
return Array.isArray(includeAttr) && includeAttr[0] === attr.field && includeAttr[1] === key;
}
......@@ -1137,7 +1137,7 @@ class Model {
// 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);
indexes = _.filter(this.options.indexes, (item1) =>
indexes = _.filter(this.options.indexes, item1 =>
!_.some(indexes, item2 => item1.name === item2.name)
).sort((index1, index2) => {
if (this.sequelize.options.dialect === 'postgres') {
......@@ -2372,7 +2372,7 @@ class Model {
}).then(() => {
// map fields back to attributes
instances.forEach((instance) => {
instances.forEach(instance => {
for (const attr in this.rawAttributes) {
if (this.rawAttributes[attr].field &&
instance.dataValues[this.rawAttributes[attr].field] !== undefined &&
......@@ -2539,7 +2539,7 @@ class Model {
if (options.individualHooks) {
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))
.then((_instances) => {
.then(_instances => {
instances = _instances;
});
}
......@@ -3488,7 +3488,7 @@ class Model {
return instance.save(includeOptions).then(() => this[include.association.accessors.set](instance, {save: false, logging: options.logging}));
});
}).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 (!this.changed() && !this.isNewRecord) return this;
......
......@@ -996,7 +996,7 @@ class Sequelize {
if (!ns) return fn();
let res;
ns.run((context) => res = fn(context));
ns.run(context => res = fn(context));
return res;
}
......@@ -1024,7 +1024,7 @@ class Sequelize {
options = last;
// 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);
}
} else {
......
......@@ -229,7 +229,7 @@ class Transaction {
* @property REPEATABLE_READ
* @property SERIALIZABLE
*/
static get ISOLATION_LEVELS () {
static get ISOLATION_LEVELS() {
return {
READ_UNCOMMITTED: 'READ UNCOMMITTED',
READ_COMMITTED: 'READ COMMITTED',
......
......@@ -53,7 +53,7 @@ exports.isPrimitive = isPrimitive;
// Same concept as _.merge, but don't overwrite properties that have already been assigned
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 (!this._.isPlainObject(objectValue) && objectValue !== undefined) {
return objectValue;
......
......@@ -16,11 +16,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 });
}).then((user) => {
}).then(user => {
expect(user.getAssignments).to.be.ok;
return Task.create({ id: 1, userId: 1 });
}).then((task) => {
}).then(task => {
expect(task.getOwner).to.be.ok;
return Promise.all([
......@@ -42,11 +42,11 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 });
}).then((user) => {
}).then(user => {
expect(user.getASSIGNMENTS).to.be.ok;
return Task.create({ id: 1, userId: 1 });
}).then((task) => {
}).then(task => {
expect(task.getOWNER).to.be.ok;
return Promise.all([
......@@ -67,13 +67,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 });
}).then((user) => {
}).then(user => {
expect(user.getTaskz).to.be.ok;
expect(user.addTask).to.be.ok;
expect(user.addTaskz).to.be.ok;
}).then(() => {
return User.find({ where: { id: 1 }, include: [{model: Task, as: 'taskz'}] });
}).then((user) => {
}).then(user => {
expect(user.taskz).to.be.ok;
});
});
......@@ -91,13 +91,13 @@ describe(Support.getTestDialectTeaser('Alias'), () => {
return this.sequelize.sync({ force: true }).then(() => {
return User.create({ id: 1 });
}).then((user) => {
}).then(user => {
expect(user.getAssignments).to.be.ok;
expect(user.addAssignment).to.be.ok;
expect(user.addAssignments).to.be.ok;
}).then(() => {
return User.find({ where: { id: 1 }, include: [Task] });
}).then((user) => {
}).then(user => {
expect(user.assignments).to.be.ok;
});
});
......
......@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true
}
]
}).then((tasks) => {
}).then(tasks => {
expect(tasks.length).to.be.equal(2);
expect(tasks[0].title).to.be.equal('fight empire');
......@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true
}
]
}).then((tasks) => {
}).then(tasks => {
expect(tasks.length).to.be.equal(2);
expect(tasks[0].title).to.be.equal('fight empire');
expect(tasks[1].title).to.be.equal('stablish republic');
......@@ -173,7 +173,7 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
required: true
}
]
}).then((users) => {
}).then(users => {
expect(users.length).to.be.equal(1);
expect(users[0].username).to.be.equal('leia');
});
......@@ -201,17 +201,17 @@ describe(Support.getTestDialectTeaser('Multiple Level Filters'), () => {
}, {
title: 'empire'
}]).then(() => {
return User.findById(1).then((user) => {
return Project.findById(1).then((project) => {
return User.findById(1).then(user => {
return Project.findById(1).then(project => {
return user.setProjects([project]).then(() => {
return User.findById(2).then((user) => {
return Project.findById(2).then((project) => {
return User.findById(2).then(user => {
return Project.findById(2).then(project => {
return user.setProjects([project]).then(() => {
return User.findAll({
include: [
{model: Project, where: {title: 'republic'}}
]
}).then((users) => {
}).then(users => {
expect(users.length).to.be.equal(1);
expect(users[0].username).to.be.equal('leia');
});
......
......@@ -108,7 +108,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(comment.get('commentable')).to.equal('post');
expect(comment.get('isMain')).to.be.false;
return this.Post.scope('withMainComment').findById(this.post.get('id'));
}).then((post) => {
}).then(post => {
expect(post.mainComment).to.be.null;
return post.createMainComment({
title: 'I am a main post comment'
......@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
return this.post.setMainComment(comment);
}).then( function() {
return this.post.getMainComment();
}).then((mainComment) => {
}).then(mainComment => {
expect(mainComment.get('commentable')).to.equal('post');
expect(mainComment.get('isMain')).to.be.true;
expect(mainComment.get('title')).to.equal('I am a future main comment');
......@@ -167,11 +167,11 @@ describe(Support.getTestDialectTeaser('associations'), () => {
);
}).then(() => {
return self.Comment.findAll();
}).then((comments) => {
comments.forEach((comment) => {
}).then(comments => {
comments.forEach(comment => {
expect(comment.get('commentable')).to.be.ok;
});
expect(comments.map((comment) => {
expect(comments.map(comment => {
return comment.get('commentable');
}).sort()).to.deep.equal(['image', 'post', 'question']);
}).then(function() {
......@@ -229,7 +229,7 @@ describe(Support.getTestDialectTeaser('associations'), () => {
return this.sequelize.sync({force: true}).then(() => {
return self.Post.create();
}).then((post) => {
}).then(post => {
return post.createComment({
title: 'I am a post comment'
});
......@@ -503,15 +503,15 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(imageTags.length).to.equal(3);
expect(questionTags.length).to.equal(3);
expect(postTags.map((tag) => {
expect(postTags.map(tag => {
return tag.name;
}).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']);
expect(imageTags.map((tag) => {
expect(imageTags.map(tag => {
return tag.name;
}).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']);
expect(questionTags.map((tag) => {
expect(questionTags.map(tag => {
return tag.name;
}).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']);
}).then(() => {
......@@ -533,15 +533,15 @@ describe(Support.getTestDialectTeaser('associations'), () => {
expect(image.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;
}).sort()).to.deep.equal(['postTag', 'tagA', 'tagB']);
expect(image.tags.map((tag) => {
expect(image.tags.map(tag => {
return tag.name;
}).sort()).to.deep.equal(['imageTag', 'tagB', 'tagC']);
expect(question.tags.map((tag) => {
expect(question.tags.map(tag => {
return tag.name;
}).sort()).to.deep.equal(['questionTag', 'tagA', 'tagC']);
});
......
......@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Self'), () => {
return chris.addParent(john);
}).then(() => {
return john.getChilds();
}).then((children) => {
}).then(children => {
expect(_.map(children, 'id')).to.have.members([mary.id, chris.id]);
});
});
......
......@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) {
});
});
return new Promise((resolve) => {
return new Promise(resolve => {
// Wait for the transaction to be setup
const interval = setInterval(() => {
if (transactionSetup) {
......
......@@ -61,14 +61,14 @@ describe(Support.getTestDialectTeaser('Configuration'), () => {
return Sequelize.Promise.promisify(fs.access)(p, fs.R_OK | fs.W_OK);
} else { // Node v0.10 and older don't have fs.access
return Sequelize.Promise.promisify(fs.open)(p, 'r+')
.then((fd) => {
.then(fd => {
return Sequelize.Promise.promisify(fs.close)(fd);
});
}
});
return Sequelize.Promise.promisify(fs.unlink)(p)
.catch((err) => {
.catch(err => {
expect(err.code).to.equal('ENOENT');
})
.then(() => {
......
......@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
});
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');
});
......@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
});
const testSuccess = function(Type, value) {
const parse = Type.constructor.parse = sinon.spy((value) => {
const parse = Type.constructor.parse = sinon.spy(value => {
return value;
});
......@@ -288,7 +288,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return new Sequelize.Promise((resolve, reject) => {
if (/^postgres/.test(dialect)) {
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')) {
resolve(true);
} else {
......@@ -298,7 +298,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
} else {
resolve(true);
}
}).then((runTests) => {
}).then(runTests => {
if (current.dialect.supports.GEOMETRY && runTests) {
current.refreshTypes();
......@@ -430,7 +430,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
return Model.sync({ force: true })
.then(() => Model.create({ interval: [1, 4] }) )
.then(() => Model.findAll() )
.spread((m) => {
.spread(m => {
expect(m.interval[0]).to.be.eql(1);
expect(m.interval[1]).to.be.eql(4);
});
......
......@@ -75,7 +75,7 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise((resolve) => {
const resolvedPromise = new Promise(resolve => {
resolve({
queryType: 'read'
});
......@@ -121,7 +121,7 @@ describe('Connection Manager', () => {
const sequelize = Support.createSequelizeInstance(options);
const connectionManager = new ConnectionManager(Support.getTestDialect(), sequelize);
const resolvedPromise = new Promise((resolve) => {
const resolvedPromise = new Promise(resolve => {
resolve({
queryType: 'read'
});
......
......@@ -22,7 +22,7 @@ if (dialect.match(/^mssql/)) {
it('should queue concurrent requests to a connection', function() {
const User = this.User;
return expect(this.sequelize.transaction((t) => {
return expect(this.sequelize.transaction(t => {
return Promise.all([
User.findOne({
transaction: t
......
......@@ -81,8 +81,8 @@ if (dialect === 'mysql') {
self.user = null;
self.task = null;
return self.User.findAll().then((_users) => {
return self.Task.findAll().then((_tasks) => {
return self.User.findAll().then(_users => {
return self.Task.findAll().then(_tasks => {
self.user = _users[0];
self.task = _tasks[0];
});
......@@ -92,10 +92,10 @@ if (dialect === 'mysql') {
it('should correctly add an association to the dao', function() {
const self = this;
return self.user.getTasks().then((_tasks) => {
return self.user.getTasks().then(_tasks => {
expect(_tasks.length).to.equal(0);
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);
});
});
......@@ -110,8 +110,8 @@ if (dialect === 'mysql') {
self.user = null;
self.tasks = null;
return self.User.findAll().then((_users) => {
return self.Task.findAll().then((_tasks) => {
return self.User.findAll().then(_users => {
return self.Task.findAll().then(_tasks => {
self.user = _users[0];
self.tasks = _tasks;
});
......@@ -121,16 +121,16 @@ if (dialect === 'mysql') {
it('should correctly remove associated objects', function() {
const self = this;
return self.user.getTasks().then((__tasks) => {
return self.user.getTasks().then(__tasks => {
expect(__tasks.length).to.equal(0);
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);
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);
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);
});
});
......
......@@ -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
return sequelize.query('SELECT COUNT(*) AS count FROM Users', { type: sequelize.QueryTypes.SELECT });
})
.then((count) => {
.then(count => {
expect(count[0].count).to.equal(1);
});
});
......@@ -67,7 +67,7 @@ if (dialect === 'mysql') {
// Get next available connection
return cm.getConnection();
})
.then((connection) => {
.then(connection => {
// Old threadId should be different from current new one
expect(conn.threadId).to.be.equal(connection.threadId);
expect(cm.validate(conn)).to.be.ok;
......@@ -84,7 +84,7 @@ if (dialect === 'mysql') {
return sequelize
.sync()
.then(() => cm.getConnection())
.then((connection) => {
.then(connection => {
// Save current connection
conn = connection;
// simulate a unexpected end
......@@ -95,7 +95,7 @@ if (dialect === 'mysql') {
// Get next available connection
return cm.getConnection();
})
.then((connection) => {
.then(connection => {
// Old threadId should be different from current new one
expect(conn.threadId).to.not.be.equal(connection.threadId);
expect(cm.validate(conn)).to.not.be.ok;
......
......@@ -69,8 +69,8 @@ if (dialect.match(/^postgres/)) {
return this.sequelize.sync({ force: true }).then(() => {
return self.User.bulkCreate(users).then(() => {
return self.Task.bulkCreate(tasks).then(() => {
return self.User.findAll().then((_users) => {
return self.Task.findAll().then((_tasks) => {
return self.User.findAll().then(_users => {
return self.Task.findAll().then(_tasks => {
self.user = _users[0];
self.task = _tasks[0];
});
......@@ -83,10 +83,10 @@ if (dialect.match(/^postgres/)) {
it('should correctly add an association to the dao', function() {
const self = this;
return self.user.getTasks().then((_tasks) => {
return self.user.getTasks().then(_tasks => {
expect(_tasks).to.have.length(0);
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);
});
});
......@@ -120,23 +120,23 @@ if (dialect.match(/^postgres/)) {
return this.sequelize.sync({ force: true }).then(() => {
return self.User.bulkCreate(users).then(() => {
return self.Task.bulkCreate(tasks).then(() => {
return self.User.findAll().then((_users) => {
return self.Task.findAll().then((_tasks) => {
return self.User.findAll().then(_users => {
return self.Task.findAll().then(_tasks => {
self.user = _users[0];
self.task = _tasks[0];
self.users = _users;
self.tasks = _tasks;
return self.user.getTasks().then((__tasks) => {
return self.user.getTasks().then(__tasks => {
expect(__tasks).to.have.length(0);
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);
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);
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);
});
});
......
......@@ -15,7 +15,7 @@ if (dialect.match(/^postgres/)) {
const tzTable = sequelize.define('tz_table', { foo: DataTypes.STRING });
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;
});
});
......
......@@ -959,19 +959,19 @@ if (dialect.match(/^postgres/)) {
.then(() => {
return Promise.all([
this.Student.findById(1)
.then((Harry) => {
.then(Harry => {
return Harry.setClasses([1, 2, 3]);
}),
this.Student.findById(2)
.then((Ron) => {
.then(Ron => {
return Ron.setClasses([1, 2]);
}),
this.Student.findById(3)
.then((Ginny) => {
.then(Ginny => {
return Ginny.setClasses([2, 3]);
}),
this.Student.findById(4)
.then((Hermione) => {
.then(Hermione => {
return Hermione.setClasses([1, 2, 3]);
})
]);
......@@ -995,7 +995,7 @@ if (dialect.match(/^postgres/)) {
]
});
})
.then((professors) => {
.then(professors => {
expect(professors.length).to.eql(2);
expect(professors[0].fullName).to.eql('Albus Dumbledore');
expect(professors[0].Classes.length).to.eql(1);
......
......@@ -24,7 +24,7 @@ if (dialect === 'sqlite') {
return this.User.sync({ force: true });
});
storages.forEach((storage) => {
storages.forEach(storage => {
describe('with storage "' + storage + '"', () => {
after(() => {
if (storage === dbFile) {
......@@ -35,13 +35,13 @@ if (dialect === 'sqlite') {
describe('create', () => {
it('creates a table entry', function() {
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.name).to.equal('John Wayne');
expect(user.bio).to.equal('noot noot');
return self.User.findAll().then((users) => {
const usernames = users.map((user) => {
return self.User.findAll().then(users => {
const usernames = users.map(user => {
return user.name;
});
expect(usernames).to.contain('John Wayne');
......@@ -61,7 +61,7 @@ if (dialect === 'sqlite') {
return Person.create({
name: 'John Doe',
options
}).then((people) => {
}).then(people => {
expect(people.options).to.deep.equal(options);
});
});
......@@ -77,7 +77,7 @@ if (dialect === 'sqlite') {
return Person.create({
name: 'John Doe',
has_swag: true
}).then((people) => {
}).then(people => {
expect(people.has_swag).to.be.ok;
});
});
......@@ -93,7 +93,7 @@ if (dialect === 'sqlite') {
return Person.create({
name: 'John Doe',
has_swag: false
}).then((people) => {
}).then(people => {
expect(people.has_swag).to.not.be.ok;
});
});
......@@ -106,13 +106,13 @@ if (dialect === 'sqlite') {
});
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');
});
});
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');
});
});
......@@ -127,7 +127,7 @@ if (dialect === 'sqlite') {
});
it('should return all users', function() {
return this.User.findAll().then((users) => {
return this.User.findAll().then(users => {
expect(users).to.have.length(2);
});
});
......@@ -143,7 +143,7 @@ if (dialect === 'sqlite') {
}
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);
});
});
......@@ -160,7 +160,7 @@ if (dialect === 'sqlite') {
}
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);
});
});
......
......@@ -184,7 +184,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), () => {
type: 'ValidationError',
exception: Sequelize.ValidationError
}
].forEach((constraintTest) => {
].forEach(constraintTest => {
it('Can be intercepted as ' + constraintTest.type + ' using .catch', function() {
const spy = sinon.spy(),
......
......@@ -111,18 +111,18 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return Promise.resolve();
});
this.User.beforeCreate((user) => {
this.User.beforeCreate(user => {
user.beforeHookTest = true;
return Promise.resolve();
});
this.User.afterCreate((user) => {
this.User.afterCreate(user => {
user.username = 'User' + user.id;
return Promise.resolve();
});
return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).then((records) => {
records.forEach((record) => {
return this.User.bulkCreate([{aNumber: 5}, {aNumber: 7}, {aNumber: 3}], { fields: ['aNumber'], individualHooks: true }).then(records => {
records.forEach(record => {
expect(record.username).to.equal('User' + record.id);
expect(record.beforeHookTest).to.be.true;
});
......@@ -149,12 +149,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return Promise.reject(new Error('You shall not pass!'));
});
this.User.afterCreate((user) => {
this.User.afterCreate(user => {
user.username = 'User' + user.id;
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(beforeBulkCreate).to.be.true;
expect(afterBulkCreate).to.be.false;
......@@ -246,12 +246,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.afterBulkUpdate(afterBulk);
this.User.beforeUpdate((user) => {
this.User.beforeUpdate(user => {
expect(user.changed()).to.not.be.empty;
user.beforeHookTest = true;
});
this.User.afterUpdate((user) => {
this.User.afterUpdate(user => {
user.username = 'User' + user.id;
});
......@@ -259,7 +259,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
{aNumber: 1}, {aNumber: 1}, {aNumber: 1}
]).then(() => {
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.beforeHookTest).to.be.true;
});
......@@ -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() {
const self = this;
this.User.beforeUpdate((user) => {
this.User.beforeUpdate(user => {
expect(user.changed()).to.not.be.empty;
if (user.get('id') === 1) {
user.set('aNumber', user.get('aNumber') + 3);
......@@ -283,7 +283,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
{aNumber: 1}, {aNumber: 1}, {aNumber: 1}
]).then(() => {
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));
});
});
......@@ -303,12 +303,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
throw new Error('You shall not pass!');
});
this.User.afterUpdate((user) => {
this.User.afterUpdate(user => {
user.username = 'User' + user.id;
});
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.message).to.be.equal('You shall not pass!');
expect(beforeBulk).to.have.been.calledOnce;
......@@ -440,7 +440,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
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(beforeBulk).to.be.true;
expect(beforeHook).to.be.true;
......@@ -555,7 +555,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
return self.ParanoidUser.destroy({where: {aNumber: 1}});
}).then(() => {
return self.ParanoidUser.restore({where: {aNumber: 1}, individualHooks: true});
}).catch((err) => {
}).catch(err => {
expect(err).to.be.instanceOf(Error);
expect(beforeBulk).to.have.been.calledOnce;
expect(beforeHook).to.have.been.calledThrice;
......
......@@ -37,14 +37,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
beforeHook = true;
});
return this.User.count().then((count) => {
return this.User.count().then(count => {
expect(count).to.equal(3);
expect(beforeHook).to.be.true;
});
});
it('beforeCount hook can change options', function() {
this.User.beforeCount((options) => {
this.User.beforeCount(options => {
options.where.username = 'adam';
});
......
......@@ -126,12 +126,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeValidate', function(){
let hookCalled = 0;
this.User.beforeValidate((user) => {
this.User.beforeValidate(user => {
user.mood = 'happy';
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.username).to.equal('leafninja');
expect(hookCalled).to.equal(1);
......@@ -141,12 +141,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('afterValidate', function() {
let hookCalled = 0;
this.User.afterValidate((user) => {
this.User.afterValidate(user => {
user.mood = 'neutral';
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.username).to.equal('fireninja');
expect(hookCalled).to.equal(1);
......@@ -156,12 +156,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeCreate', function() {
let hookCalled = 0;
this.User.beforeCreate((user) => {
this.User.beforeCreate(user => {
user.mood = 'happy';
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.username).to.equal('akira');
expect(hookCalled).to.equal(1);
......@@ -171,12 +171,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave', function() {
let hookCalled = 0;
this.User.beforeSave((user) => {
this.User.beforeSave(user => {
user.mood = 'happy';
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.username).to.equal('akira');
expect(hookCalled).to.equal(1);
......@@ -186,17 +186,17 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave with beforeCreate', function() {
let hookCalled = 0;
this.User.beforeCreate((user) => {
this.User.beforeCreate(user => {
user.mood = 'sad';
hookCalled++;
});
this.User.beforeSave((user) => {
this.User.beforeSave(user => {
user.mood = 'happy';
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.username).to.equal('akira');
expect(hookCalled).to.equal(2);
......
......@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeDestroy(beforeHook);
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(() => {
expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce;
......@@ -50,7 +50,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
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(() => {
expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).not.to.have.been.called;
......@@ -68,7 +68,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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(() => {
expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce;
......
......@@ -30,7 +30,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
it('allow changing attributes via beforeFind #5675', function() {
this.User.beforeFind((options) => {
this.User.beforeFind(options => {
options.attributes = {
include: ['id']
};
......@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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(beforeHook).to.be.true;
expect(beforeHook2).to.be.true;
......@@ -71,41 +71,41 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
it('beforeFind hook can change options', function() {
this.User.beforeFind((options) => {
this.User.beforeFind(options => {
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');
});
});
it('beforeFindAfterExpandIncludeAll hook can change options', function() {
this.User.beforeFindAfterExpandIncludeAll((options) => {
this.User.beforeFindAfterExpandIncludeAll(options => {
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');
});
});
it('beforeFindAfterOptions hook can change options', function() {
this.User.beforeFindAfterOptions((options) => {
this.User.beforeFindAfterOptions(options => {
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');
});
});
it('afterFind hook can change results', function() {
this.User.afterFind((user) => {
this.User.afterFind(user => {
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');
});
});
......@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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!');
});
});
......@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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!');
});
});
......@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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!');
});
});
......@@ -147,7 +147,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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!');
});
});
......
......@@ -43,7 +43,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
attributes.type = DataTypes.STRING;
});
this.sequelize.addHook('afterDefine', (factory) => {
this.sequelize.addHook('afterDefine', factory => {
factory.options.name.singular = 'barr';
});
......@@ -79,7 +79,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
options.host = 'server9';
});
Sequelize.addHook('afterInit', (sequelize) => {
Sequelize.addHook('afterInit', sequelize => {
sequelize.options.protocol = 'udp';
});
......@@ -186,7 +186,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => {
return User.create({ username: 'bob' }).then(user => {
return user.destroy().then(() => {
expect(beforeHooked).to.be.true;
expect(afterHooked).to.be.true;
......@@ -218,7 +218,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => {
return User.create({ username: 'bob' }).then(user => {
return user.destroy().then(() => {
expect(beforeHooked).to.be.true;
expect(afterHooked).to.be.true;
......@@ -250,7 +250,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
return User.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((user) => {
return User.create({ username: 'bob' }).then(user => {
user.username = 'bawb';
return user.save({ fields: ['username'] }).then(() => {
expect(beforeHooked).to.be.true;
......@@ -457,7 +457,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.hook('beforeSave', sasukeHook);
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(narutoHook).to.have.been.calledOnce;
this.User.removeHook('beforeSave', sasukeHook);
......
......@@ -41,7 +41,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.ParanoidUser.beforeRestore(beforeHook);
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.restore().then(() => {
expect(beforeHook).to.have.been.calledOnce;
......@@ -63,7 +63,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
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 expect(user.restore()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce;
......@@ -83,7 +83,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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 expect(user.restore()).to.be.rejected.then(() => {
expect(beforeHook).to.have.been.calledOnce;
......
......@@ -34,8 +34,8 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave);
this.User.afterSave(afterSave);
return this.User.create({username: 'Toni', mood: 'happy'}).then((user) => {
return user.updateAttributes({username: 'Chong'}).then((user) => {
return this.User.create({username: 'Toni', mood: 'happy'}).then(user => {
return user.updateAttributes({username: 'Chong'}).then(user => {
expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce;
expect(beforeSave).to.have.been.calledTwice;
......@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave);
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(() => {
expect(beforeHook).to.have.been.calledOnce;
expect(beforeSave).to.have.been.calledOnce;
......@@ -85,7 +85,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
this.User.beforeSave(beforeSave);
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(() => {
expect(beforeHook).to.have.been.calledOnce;
expect(afterHook).to.have.been.calledOnce;
......@@ -99,13 +99,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('preserves changes to instance', () => {
it('beforeValidate', function(){
this.User.beforeValidate((user) => {
this.User.beforeValidate(user => {
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'});
}).then((user) => {
}).then(user => {
expect(user.username).to.equal('hero');
expect(user.mood).to.equal('happy');
});
......@@ -113,13 +113,13 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('afterValidate', function() {
this.User.afterValidate((user) => {
this.User.afterValidate(user => {
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'});
}).then((user) => {
}).then(user => {
expect(user.username).to.equal('spider');
expect(user.mood).to.equal('sad');
});
......@@ -128,14 +128,14 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave', function() {
let hookCalled = 0;
this.User.beforeSave((user) => {
this.User.beforeSave(user => {
user.mood = 'happy';
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'});
}).then((user) => {
}).then(user => {
expect(user.username).to.equal('spider');
expect(user.mood).to.equal('happy');
expect(hookCalled).to.equal(2);
......@@ -145,19 +145,19 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('beforeSave with beforeUpdate', function() {
let hookCalled = 0;
this.User.beforeUpdate((user) => {
this.User.beforeUpdate(user => {
user.mood = 'sad';
hookCalled++;
});
this.User.beforeSave((user) => {
this.User.beforeSave(user => {
user.mood = 'happy';
hookCalled++;
});
return this.User.create({username: 'akira'}).then((user) => {
return this.User.create({username: 'akira'}).then(user => {
return user.updateAttributes({username: 'spider', mood: 'sad'});
}).then((user) => {
}).then(user => {
expect(user.mood).to.equal('happy');
expect(user.username).to.equal('spider');
expect(hookCalled).to.equal(3);
......
......@@ -78,7 +78,7 @@ if (Support.sequelize.dialect.supports.upserts) {
let hookCalled = 0;
const valuesOriginal = { mood: 'sad', username: 'leafninja' };
this.User.beforeUpsert((values) => {
this.User.beforeUpsert(values => {
values.mood = 'happy';
hookCalled++;
});
......
......@@ -24,16 +24,16 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('#validate', () => {
describe('#create', () => {
it('should return the user', function() {
this.User.beforeValidate((user) => {
this.User.beforeValidate(user => {
user.username = 'Bob';
user.mood = 'happy';
});
this.User.afterValidate((user) => {
this.User.afterValidate(user => {
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.username).to.equal('Toni');
});
......@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
it('fields modified in hooks are saved', function() {
const self = this;
this.User.afterValidate((user) => {
this.User.afterValidate(user => {
//if username is defined and has more than 5 char
user.username = user.username
? user.username.length < 5 ? null : user.username
......@@ -53,12 +53,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
});
this.User.beforeValidate((user) => {
this.User.beforeValidate(user => {
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.username).to.equal('Samorost 3');
......@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
user.username = 'Samorost Good One';
return user.save();
}).then((uSaved) => {
}).then(uSaved => {
expect(uSaved.mood).to.equal('sad');
expect(uSaved.username).to.equal('Samorost Good One');
......@@ -75,12 +75,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uSaved.username = 'One';
return uSaved.save();
}).then((uSaved) => {
}).then(uSaved => {
//attributes were replaced by hooks ?
expect(uSaved.mood).to.equal('sad');
expect(uSaved.username).to.equal('Samorost 3');
return self.User.findById(uSaved.id);
}).then((uFetched) => {
}).then(uFetched => {
expect(uFetched.mood).to.equal('sad');
expect(uFetched.username).to.equal('Samorost 3');
......@@ -88,12 +88,12 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uFetched.username = 'New Game is Needed';
return uFetched.save();
}).then((uFetchedSaved) => {
}).then(uFetchedSaved => {
expect(uFetchedSaved.mood).to.equal('neutral');
expect(uFetchedSaved.username).to.equal('New Game is Needed');
return self.User.findById(uFetchedSaved.id);
}).then((uFetched) => {
}).then(uFetched => {
expect(uFetched.mood).to.equal('neutral');
expect(uFetched.username).to.equal('New Game is Needed');
......@@ -101,7 +101,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
uFetched.username = 'New';
uFetched.mood = 'happy';
return uFetched.save();
}).then((uFetchedSaved) => {
}).then(uFetchedSaved => {
expect(uFetchedSaved.mood).to.equal('happy');
expect(uFetchedSaved.username).to.equal('Samorost 3');
});
......@@ -110,7 +110,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
describe('on error', () => {
it('should emit an error from after hook', function() {
this.User.afterValidate((user) => {
this.User.afterValidate(user => {
user.mood = 'ecstatic';
throw new Error('Whoops! Changed user.mood!');
});
......@@ -133,7 +133,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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');
});
});
......@@ -143,7 +143,7 @@ describe(Support.getTestDialectTeaser('Hooks'), () => {
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!');
});
});
......
......@@ -26,7 +26,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => {
return User.find({
include: [{model: Company, as: 'Employer'}]
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => {
return User.findOne({
include: [Employer]
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -56,7 +56,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({force: true}).then(() => {
return Company.create({
name: 'CyberCorp'
}).then((company) => {
}).then(company => {
return User.create({
employerId: company.get('id')
});
......@@ -66,7 +66,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [
{association: Employer, where: {name: 'CyberCorp'}}
]
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Company.create().then(() => {
return Company.find({
include: [{model: Person, as: 'CEO'}]
}).then((company) => {
}).then(company => {
expect(company).to.be.ok;
});
});
......@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Company.find({
include: [CEO]
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}).then(() => {
return Person.find({
include: [Person.relation.Employer]
}).then((person) => {
}).then(person => {
expect(person).to.be.ok;
expect(person.employer).to.be.ok;
});
......@@ -138,13 +138,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User);
return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => {
return User.create().then(user => {
return user.createTask();
}).then(() => {
return User.find({
include: [Tasks]
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.tasks).to.be.ok;
});
......@@ -159,7 +159,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User);
return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => {
return User.create().then(user => {
return Promise.join(
user.createTask({
title: 'trivial'
......@@ -174,7 +174,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{association: Tasks, where: {title: 'trivial'}}
]
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.tasks).to.be.ok;
expect(user.tasks.length).to.equal(1);
......@@ -190,13 +190,13 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Group.belongsToMany(User, { through: 'UserGroup' });
return this.sequelize.sync({force: true}).then(() => {
return User.create().then((user) => {
return User.create().then(user => {
return user.createGroup();
});
}).then(() => {
return User.find({
include: [Groups]
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.groups).to.be.ok;
});
......@@ -216,12 +216,12 @@ describe(Support.getTestDialectTeaser('Include'), () => {
task: Task.create(),
user: User.create(),
group: Group.create()
}).then((props) => {
}).then(props => {
return Promise.join(
props.task.setUser(props.user),
props.user.setGroup(props.group)
).return(props);
}).then((props) => {
}).then(props => {
return Task.findOne({
where: {
id: props.task.id
......@@ -231,7 +231,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Group}
]}
]
}).then((task) => {
}).then(task => {
expect(task.User).to.be.ok;
expect(task.User.Group).to.be.ok;
});
......@@ -254,7 +254,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, {
include: [User, Group]
});
}).then((task) => {
}).then(task => {
return Task.find({
where: {
id: task.id
......@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Group}
]
});
}).then((task) => {
}).then(task => {
expect(task.User).to.be.ok;
expect(task.Group).to.be.ok;
});
......@@ -286,7 +286,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, {
include: [Task, Group]
});
}).then((user) => {
}).then(user => {
return Group.find({
where: {
id: user.Group.id
......@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]}
]
});
}).then((group) => {
}).then(group => {
expect(group.User).to.be.ok;
expect(group.User.Task).to.be.ok;
});
......@@ -324,7 +324,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, {
include: [Task]
});
}).then((user) => {
}).then(user => {
return User.find({
where: {
id: user.id
......@@ -335,11 +335,11 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]}
]
});
}).then((user) => {
}).then(user => {
expect(user.Tasks).to.be.ok;
expect(user.Tasks.length).to.equal(4);
user.Tasks.forEach((task) => {
user.Tasks.forEach(task => {
expect(task.Project).to.be.ok;
});
});
......@@ -361,7 +361,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}, {
include: [Worker, Task]
});
}).then((project) => {
}).then(project => {
return Worker.find({
where: {
id: project.Workers[0].id
......@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]}
]
});
}).then((worker) => {
}).then(worker => {
expect(worker.Project).to.be.ok;
expect(worker.Project.Tasks).to.be.ok;
expect(worker.Project.Tasks.length).to.equal(4);
......@@ -436,7 +436,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
[Product, 'id']
]
});
}).then((user) => {
}).then(user => {
expect(user.Products.length).to.equal(4);
expect(user.Products[0].Tags.length).to.equal(2);
expect(user.Products[1].Tags.length).to.equal(1);
......@@ -541,7 +541,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]}
]
});
}).then((user) => {
}).then(user => {
user.Memberships.sort(sortById);
expect(user.Memberships.length).to.equal(2);
expect(user.Memberships[0].Group.name).to.equal('Developers');
......@@ -588,7 +588,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Project, attributes: ['title']}
]
});
}).then((tasks) => {
}).then(tasks => {
expect(tasks[0].title).to.equal('FooBar');
expect(tasks[0].Project.title).to.equal('BarFoo');
......@@ -608,7 +608,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({ force: true }).then(() => {
return Post.create({});
}).then((post) => {
}).then(post => {
return post.createPostComment({
comment_title: 'WAT'
});
......@@ -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('someProperty2')).to.be.ok;
expect(posts[0].PostComments[0].get('commentTitle')).to.equal('WAT');
......@@ -668,7 +668,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
},
include: [{model: Group, as: 'OutsourcingCompanies'}]
});
}).then((group) => {
}).then(group => {
expect(group.OutsourcingCompanies).to.have.length(3);
});
});
......@@ -699,7 +699,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
},
include: [Group]
});
}).then((user) => {
}).then(user => {
expect(user.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'), () => {
as: 'Members'
}]
});
}).then((groups) => {
}).then(groups => {
expect(groups.length).to.equal(1);
expect(groups[0].Members[0].name).to.equal('Member');
});
......@@ -796,7 +796,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [
{model: this.Item, where: Sequelize.and({ test: 'def' })}
]
}).then((result) => {
}).then(result => {
expect(result.length).to.eql(1);
expect(result[0].Item.test).to.eql('def');
});
......@@ -825,7 +825,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}}
]
});
}).then((result) => {
}).then(result => {
expect(result.count).to.eql(1);
expect(result.rows.length).to.eql(1);
......@@ -848,7 +848,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return this.sequelize.sync({force: true}).then(() => {
return Questionnaire.create();
}).then((questionnaire) => {
}).then(questionnaire => {
return questionnaire.getQuestions({
include: Answer
});
......@@ -880,7 +880,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Employee.create({ name: 'Jill' }),
Clearence.create({ level: 3 }),
Clearence.create({ level: 5 })
]).then((instances) => {
]).then(instances => {
return Promise.all([
instances[0].addMembers([instances[2], instances[3]]),
instances[1].addMembers([instances[4], instances[5]]),
......@@ -905,7 +905,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
}
]
}).then((teams) => {
}).then(teams => {
expect(teams).to.have.length(2);
});
});
......@@ -923,7 +923,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
}
]
}).then((teams) => {
}).then(teams => {
expect(teams).to.have.length(2);
});
});
......@@ -942,7 +942,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
}
]
}).then((teams) => {
}).then(teams => {
expect(teams).to.have.length(1);
});
});
......
......@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
force: true
}).then(() => {
return User.create();
}).then((user) => {
}).then(user => {
return Task.bulkCreate([
{userId: user.get('id'), deletedAt: new Date()},
{userId: user.get('id'), deletedAt: new Date()},
......@@ -90,7 +90,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Task, where: {deletedAt: null}, required: false}
]
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.Tasks.length).to.equal(0);
});
......@@ -116,7 +116,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
force: true
}).then(() => {
return User.create();
}).then((user) => {
}).then(user => {
return Task.bulkCreate([
{userId: user.get('id'), searchString: 'one'},
{userId: user.get('id'), searchString: 'two'}
......@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
{model: Task, where: {searchString: 'one'} }
]
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.Tasks.length).to.equal(1);
});
......@@ -165,7 +165,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
});
})
.then((a) => {
.then(a => {
expect(a).to.not.equal(null);
expect(a.get('bs')).to.have.length(1);
});
......@@ -198,7 +198,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
});
})
.then((a) => {
.then(a => {
expect(a).to.not.equal(null);
expect(a.get('bs')).to.deep.equal([]);
});
......@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
});
})
.then((a) => {
.then(a => {
expect(a).to.not.exist;
});
});
......@@ -252,14 +252,14 @@ describe(Support.getTestDialectTeaser('Include'), () => {
Task.belongsTo(User, { foreignKey: 'user_name', targetKey: 'username'});
return this.sequelize.sync({ force: true }).then(() => {
return User.create({ username: 'bob' }).then((newUser) => {
return Task.create({ title: 'some task' }).then((newTask) => {
return User.create({ username: 'bob' }).then(newUser => {
return Task.create({ title: 'some task' }).then(newTask => {
return newTask.setUser(newUser).then(() => {
return Task.find({
where: { title: 'some task' },
include: [ { model: User } ]
})
.then((foundTask) => {
.then(foundTask => {
expect(foundTask).to.be.ok;
expect(foundTask.User.username).to.equal('bob');
});
......@@ -299,7 +299,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
previousInstance,
b;
singles.forEach((model) => {
singles.forEach(model => {
const values = {};
if (model.name === 'g') {
......@@ -307,7 +307,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}
promise = promise.then(() => {
return model.create(values).then((instance) => {
return model.create(values).then(instance => {
if (previousInstance) {
return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => {
previousInstance = instance;
......@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]}
]}
]
}).then((a) => {
}).then(a => {
expect(a.b.c.d.e.f.g.h).to.be.ok;
});
});
......
......@@ -113,7 +113,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}
}],
limit: 5
}).then((result ) => {
}).then(result => {
expect(result.count).to.be.equal(2);
expect(result.rows.length).to.be.equal(2);
});
......@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Project.sync({force: true});
}).then(() => {
return Promise.all([User.create(), Project.create(), Project.create(), Project.create()]);
}).then((results) => {
}).then(results => {
const user = results[0];
userId = user.id;
return user.setProjects([results[1], results[2], results[3]]);
......@@ -151,7 +151,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
include: [Project],
distinct: true
});
}).then((result) => {
}).then(result => {
expect(result.rows.length).to.equal(1);
expect(result.rows[0].Projects.length).to.equal(3);
expect(result.count).to.equal(1);
......@@ -181,11 +181,11 @@ describe(Support.getTestDialectTeaser('Include'), () => {
return Foo.findAll({
include: [{ model: Bar, required: true }],
limit: 2
}).then((items) => {
}).then(items => {
expect(items.length).to.equal(2);
});
});
}).then((result) => {
}).then(result => {
expect(result.count).to.equal(4);
// The first two of those should be returned due to the limit (Foo
......@@ -213,7 +213,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
limit: 1,
distinct: true
});
}).then((result) => {
}).then(result => {
// There should be 2 instances matching the query (Instances 1 and 2), see the findAll statement
expect(result.count).to.equal(2);
......@@ -289,7 +289,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
]
});
});
}).then((result) => {
}).then(result => {
expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(1);
});
......@@ -340,7 +340,7 @@ describe(Support.getTestDialectTeaser('Include'), () => {
}
]
});
}).then((result) => {
}).then(result => {
expect(result.count).to.equal(2);
expect(result.rows.length).to.equal(1);
});
......
......@@ -123,7 +123,7 @@ describe(Support.getTestDialectTeaser('Paranoid'), () => {
return X.findAll({
include: [Y]
}).get(0);
}).then((x) => {
}).then(x => {
expect(x.ys).to.have.length(0);
});
});
......
......@@ -120,7 +120,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Tag.findAll()
]);
}).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([
AccUser.create(),
Product.bulkCreate([
......@@ -262,7 +262,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
return Tag.findAll();
})
]).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([
AccUser.create(),
Product.bulkCreate([
......@@ -316,8 +316,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [
[AccUser.rawAttributes.id, 'ASC']
]
}).then((users) => {
users.forEach((user) => {
}).then(users => {
users.forEach(user => {
expect(user.Memberships).to.be.ok;
user.Memberships.sort(sortById);
......@@ -378,8 +378,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
{}, {}, {}, {}, {}, {}, {}, {}
]).then(() => {
let previousInstance;
return Promise.each(singles, (model) => {
return model.create({}).then((instance) => {
return Promise.each(singles, model => {
return model.create({}).then(instance => {
if (previousInstance) {
return previousInstance['set'+ Sequelize.Utils.uppercaseFirst(model.name)](instance).then(() => {
previousInstance = instance;
......@@ -391,9 +391,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
});
}).then(() => {
return A.findAll();
}).then((as) => {
}).then(as => {
const promises = [];
as.forEach((a) => {
as.forEach(a => {
promises.push(a.setB(b));
});
return Promise.all(promises);
......@@ -414,9 +414,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]}
]}
]
}).then((as) => {
}).then(as => {
expect(as.length).to.be.ok;
as.forEach((a) => {
as.forEach(a => {
expect(a.b.c.d.e.f.g.h).to.be.ok;
});
});
......@@ -474,7 +474,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
'order': [
[Order, 'position']
]
}).then((as) => {
}).then(as => {
expect(as.length).to.eql(2);
expect(as[0].itemA.test).to.eql('abc');
expect(as[1].itemA.test).to.eql('abc');
......@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
['id', 'ASC'],
[Tag, 'id', 'ASC']
]
}).then((products) => {
}).then(products => {
expect(products[0].Tags[0].ProductTag.priority).to.equal(1);
expect(products[0].Tags[1].ProductTag.priority).to.equal(2);
expect(products[1].Tags[0].ProductTag.priority).to.equal(1);
......@@ -568,7 +568,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [
{model: Group, required: true}
]
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
expect(users[0].Group).to.be.ok;
});
......@@ -606,7 +606,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [
{model: Group, where: {name: 'A'}}
]
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
expect(users[0].Group).to.be.ok;
expect(users[0].Group.name).to.equal('A');
......@@ -645,8 +645,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [
{model: Group, required: true}
]
}).then((users) => {
users.forEach((user) => {
}).then(users => {
users.forEach(user => {
expect(user.Group).to.be.ok;
});
});
......@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setGroup(groups[1]),
users[1].setGroup(groups[0])
];
groups.forEach((group) => {
groups.forEach(group => {
promises.push(group.setCategories(categories));
});
return Promise.all(promises);
......@@ -697,9 +697,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]}
],
limit: 1
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.Group).to.be.ok;
expect(user.Group.Categories).to.be.ok;
});
......@@ -739,7 +739,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setTeam(groups[1]),
users[1].setTeam(groups[0])
];
groups.forEach((group) => {
groups.forEach(group => {
promises.push(group.setTags(categories));
});
return Promise.all(promises);
......@@ -751,9 +751,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]}
],
limit: 1
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.Team).to.be.ok;
expect(user.Team.Tags).to.be.ok;
});
......@@ -793,7 +793,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users[0].setGroup(groups[1]),
users[1].setGroup(groups[0])
];
groups.forEach((group) => {
groups.forEach(group => {
promises.push(group.setCategories(categories));
});
return Promise.all(promises);
......@@ -805,9 +805,9 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
]}
],
limit: 1
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.Group).to.be.ok;
expect(user.Group.Categories).to.be.ok;
});
......@@ -846,7 +846,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [
{model: Project, as: 'LeaderOf', where: {title: 'Beta'}}
]
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
expect(users[0].LeaderOf).to.be.ok;
expect(users[0].LeaderOf.title).to.equal('Beta');
......@@ -900,7 +900,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
include: [
{model: Tag, where: {name: 'C'}}
]
}).then((products) => {
}).then(products => {
expect(products.length).to.equal(1);
expect(products[0].Tags.length).to.equal(1);
});
......@@ -977,7 +977,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Tag.findAll()
]);
}).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([
User.create({name: 'FooBarzz'}),
Product.bulkCreate([
......@@ -1035,8 +1035,8 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [
['id', 'ASC']
]
}).then((users) => {
users.forEach((user) => {
}).then(users => {
users.forEach(user => {
expect(user.Memberships.length).to.equal(1);
expect(user.Memberships[0].Rank.name).to.equal('Admin');
expect(user.Products.length).to.equal(1);
......@@ -1066,7 +1066,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
users: User.bulkCreate([{}, {}, {}, {}]).then(() => {
return User.findAll();
})
}).then((results) => {
}).then(results => {
return Promise.join(
results.users[1].setGroup(results.groups[0]),
results.users[2].setGroup(results.groups[0]),
......@@ -1079,10 +1079,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
{model: Group, where: {name: 'A'}}
],
limit: 2
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(2);
users.forEach((user) => {
users.forEach(user => {
expect(user.Group.name).to.equal('A');
});
});
......@@ -1104,10 +1104,10 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [
['id', 'ASC']
]
}).then((products) => {
}).then(products => {
expect(products.length).to.equal(3);
products.forEach((product) => {
products.forEach(product => {
expect(product.Company.name).to.equal('NYSE');
expect(product.Tags.length).to.be.ok;
expect(product.Prices.length).to.be.ok;
......@@ -1131,14 +1131,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [
['id', 'ASC']
]
}).then((products) => {
}).then(products => {
expect(products.length).to.equal(6);
products.forEach((product) => {
products.forEach(product => {
expect(product.Tags.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);
});
});
......@@ -1159,14 +1159,14 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
order: [
['id', 'ASC']
]
}).then((products) => {
}).then(products => {
expect(products.length).to.equal(10);
products.forEach((product) => {
products.forEach(product => {
expect(product.Tags.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);
});
});
......@@ -1186,15 +1186,15 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => {
Group.belongsToMany(User, {through: 'group_user'});
return this.sequelize.sync().then(() => {
return User.create({ dateField: Date.UTC(2014, 1, 20) }).then((user) => {
return Group.create({ dateField: Date.UTC(2014, 1, 20) }).then((group) => {
return User.create({ dateField: Date.UTC(2014, 1, 20) }).then(user => {
return Group.create({ dateField: Date.UTC(2014, 1, 20) }).then(group => {
return user.addGroup(group).then(() => {
return User.findAll({
where: {
id: user.id
},
include: [Group]
}).then((users) => {
}).then(users => {
if (dialect === 'sqlite') {
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));
......
......@@ -50,7 +50,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((users) => {
}).then(users => {
expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(3);
expect(users[1].get('tasks')).to.be.ok;
......@@ -94,7 +94,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((users) => {
}).then(users => {
expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(3);
expect(sqlSpy).to.have.been.calledTwice;
......@@ -166,7 +166,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((users) => {
}).then(users => {
expect(users[0].get('tasks')).to.be.ok;
expect(users[0].get('tasks').length).to.equal(2);
expect(users[1].get('tasks')).to.be.ok;
......@@ -225,7 +225,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((users) => {
}).then(users => {
expect(users[0].get('company').get('tasks')).to.be.ok;
expect(users[0].get('company').get('tasks').length).to.equal(3);
expect(users[1].get('company').get('tasks')).to.be.ok;
......@@ -282,7 +282,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((companies) => {
}).then(companies => {
expect(sqlSpy).to.have.been.calledTwice;
expect(companies[0].users[0].tasks[0].project).to.be.ok;
......@@ -352,7 +352,7 @@ if (current.dialect.supports.groupedLimit) {
],
logging: sqlSpy
});
}).then((users) => {
}).then(users => {
const u1projects = users[0].get('projects');
expect(u1projects).to.be.ok;
......@@ -361,8 +361,8 @@ if (current.dialect.supports.groupedLimit) {
expect(u1projects.length).to.equal(2);
// WTB ES2015 syntax ...
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 === 1; }).get('tasks').length).to.equal(3);
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')[0].get('tasks')).to.be.ok;
......@@ -415,7 +415,7 @@ if (current.dialect.supports.groupedLimit) {
order: [
['id', 'ASC']
]
}).then((result) => {
}).then(result => {
expect(result[0].tasks.length).to.equal(2);
expect(result[0].tasks[0].title).to.equal('b');
expect(result[0].tasks[1].title).to.equal('d');
......
......@@ -23,11 +23,11 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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
.update({ username: 'toni' }, { where: {id: user.id }})
.then(() => {
return User.findById(1).then((user) => {
return User.findById(1).then(user => {
expect(user.username).to.equal('toni');
});
});
......@@ -47,8 +47,8 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
return Model.sync({ force: true }).then(() => {
return Model.create({name: 'World'}).then((model) => {
return model.updateAttributes({name: ''}).catch((err) => {
return Model.create({name: 'World'}).then(model => {
return model.updateAttributes({name: ''}).catch(err => {
expect(err).to.be.an.instanceOf(Error);
expect(err.get('name')[0].message).to.equal('Validation notEmpty on name failed');
});
......@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true }).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.get('name')[0].message).to.equal('Validation notEmpty on name failed');
});
......@@ -88,13 +88,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true })
.then(() => {
return Model.create(records[0]);
}).then((instance) => {
}).then(instance => {
expect(instance).to.be.ok;
return Model.create(records[1]);
}).then((instance) => {
}).then(instance => {
expect(instance).to.be.ok;
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.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName');
......@@ -116,13 +116,13 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true })
.then(() => {
return Model.create(records[0]);
}).then((instance) => {
}).then(instance => {
expect(instance).to.be.ok;
return Model.create(records[1]);
}).then((instance) => {
}).then(instance => {
expect(instance).to.be.ok;
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.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName');
......@@ -149,17 +149,17 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return Model.sync({ force: true })
.then(() => {
return Model.create(records[0]);
}).then((instance) => {
}).then(instance => {
expect(instance).to.be.ok;
return expect(Model.create(records[1])).to.be.rejected;
}).then((err) => {
}).then(err => {
expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName1');
expect(err.errors[0].message).to.equal('custom unique error message 1');
return expect(Model.create(records[2])).to.be.rejected;
}).then((err) => {
}).then(err => {
expect(err).to.be.an.instanceOf(Error);
expect(err.errors).to.have.length(1);
expect(err.errors[0].path).to.include('uniqueName2');
......@@ -198,18 +198,18 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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');
});
});
it('correctly validates using create method ', function() {
const self = this;
return this.Project.create({}).then((project) => {
return self.Task.create({something: 1}).then((task) => {
return project.setTask(task).then((task) => {
return this.Project.create({}).then(project => {
return self.Task.create({something: 1}).then(task => {
return project.setTask(task).then(task => {
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;
});
});
......@@ -232,7 +232,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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.get('id')[0].message).to.equal('Validation isInt on id failed');
});
......@@ -252,7 +252,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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.get('username')[0].message).to.equal('Username must be an integer!');
});
......@@ -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() {
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.get('id')[0].message).to.equal('ID must be an integer!');
});
......@@ -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() {
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!');
});
});
it('should emit an error when we try to .save()', function() {
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.get('id')[0].message).to.equal('ID must be an integer!');
});
......@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
it('produce 3 errors', function() {
return this.Project.create({}).catch((err) => {
return this.Project.create({}).catch(err => {
expect(err).to.be.an.instanceOf(Error);
delete err.stack; // longStackTraces
expect(err.errors).to.have.length(3);
......@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
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.get('name')[0].message).to.equal("name should equal '2'");
......@@ -392,7 +392,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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.get('name')[0].message).to.equal('Invalid username');
......@@ -416,7 +416,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
.build({ age: -1 })
.validate())
.to.be.rejected
.then((error) => {
.then(error => {
expect(error.get('age')[0].message).to.equal('must be positive');
});
});
......@@ -445,7 +445,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
.build({ field1: null, field2: null })
.validate())
.to.be.rejected
.then((error) => {
.then(error => {
expect(error.get('xnor')[0].message).to.equal('xnor failed');
return expect(Foo
......@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
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')[0].message).to.equal('Validation isIn on field failed');
});
......@@ -520,10 +520,10 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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');
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');
});
});
......@@ -655,7 +655,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
expect(User.build({
password: 'short',
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(User.build({
......@@ -666,7 +666,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
});
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;
});
......@@ -685,7 +685,7 @@ describe(Support.getTestDialectTeaser('InstanceValidator'), () => {
return expect(User.build({
name: 'a'
}).validate()).to.be.rejected;
}).then((errors) => {
}).then(errors => {
expect(errors.get('name')[0].message).to.equal('Validation isExactly7Characters on name failed');
});
});
......
......@@ -64,15 +64,15 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
if (current.dialect.supports.transactions) {
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 });
return User.sync({ force: true }).then(() => {
return User.create({ username: 'foo' }).then((user) => {
return sequelize.transaction().then((t) => {
return User.create({ username: 'foo' }).then(user => {
return sequelize.transaction().then(t => {
return user.update({ username: 'bar' }, { transaction: t }).then(() => {
return User.findAll().then((users1) => {
return User.findAll({ transaction: t }).then((users2) => {
return User.findAll().then(users1 => {
return User.findAll({ transaction: t }).then(users2 => {
expect(users1[0].username).to.equal('foo');
expect(users2[0].username).to.equal('bar');
return t.rollback();
......@@ -99,11 +99,11 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: 'email'
}, {
fields: ['name', 'email']
}).then((user) => {
}).then(user => {
return user.update({bio: 'swag'});
}).then((user) => {
}).then(user => {
return user.reload();
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email');
expect(user.get('bio')).to.equal('swag');
......@@ -126,14 +126,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: 'email'
}, {
fields: ['name', 'email']
}).then((user) => {
}).then(user => {
return user.update({
name: 'snafu',
email: 'email'
});
}).then((user) => {
}).then(user => {
return user.reload();
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email');
});
......@@ -158,9 +158,9 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return User.create({
name: 'snafu',
email: 'email'
}).then((user) => {
}).then(user => {
return user.reload();
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email');
const testDate = new Date();
......@@ -209,7 +209,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: DataTypes.STRING
});
User.beforeUpdate((instance) => {
User.beforeUpdate(instance => {
instance.set('email', 'B');
});
......@@ -218,14 +218,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A',
bio: 'A',
email: 'A'
}).then((user) => {
}).then(user => {
return user.update({
name: 'B',
bio: 'B'
});
}).then(() => {
return User.findOne({});
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('B');
expect(user.get('bio')).to.equal('B');
expect(user.get('email')).to.equal('B');
......@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
email: DataTypes.STRING
});
User.beforeUpdate((instance) => {
User.beforeUpdate(instance => {
instance.set('email', 'C');
});
......@@ -249,7 +249,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A',
bio: 'A',
email: 'A'
}).then((user) => {
}).then(user => {
return user.update({
name: 'B',
bio: 'B',
......@@ -257,7 +257,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
}).then(() => {
return User.findOne({});
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('B');
expect(user.get('bio')).to.equal('B');
expect(user.get('email')).to.equal('C');
......@@ -277,7 +277,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
}
});
User.beforeUpdate((instance) => {
User.beforeUpdate(instance => {
instance.set('email', 'B');
});
......@@ -286,12 +286,12 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A',
bio: 'A',
email: 'valid.email@gmail.com'
}).then((user) => {
}).then(user => {
return expect(user.update({
name: 'B'
})).to.be.rejectedWith(Sequelize.ValidationError);
}).then(() => {
return User.findOne({}).then((user) => {
return User.findOne({}).then(user => {
expect(user.get('email')).to.equal('valid.email@gmail.com');
});
});
......@@ -310,7 +310,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
}
});
User.beforeUpdate((instance) => {
User.beforeUpdate(instance => {
instance.set('email', 'B');
});
......@@ -319,13 +319,13 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'A',
bio: 'A',
email: 'valid.email@gmail.com'
}).then((user) => {
}).then(user => {
return expect(user.update({
name: 'B',
email: 'still.valid.email@gmail.com'
})).to.be.rejectedWith(Sequelize.ValidationError);
}).then(() => {
return User.findOne({}).then((user) => {
return User.findOne({}).then(user => {
expect(user.get('email')).to.equal('valid.email@gmail.com');
});
});
......@@ -344,14 +344,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return User.create({
name: 'snafu',
email: 'email'
}).then((user) => {
}).then(user => {
return user.update({
bio: 'heyo',
email: 'heho'
}, {
fields: ['bio']
});
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('snafu');
expect(user.get('email')).to.equal('email');
expect(user.get('bio')).to.equal('heyo');
......@@ -360,17 +360,17 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
});
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');
return user.update({ username: 'person' }).then((user) => {
return user.update({ username: 'person' }).then(user => {
expect(user.username).to.equal('person');
});
});
});
it('ignores unknown attributes', function() {
return this.User.create({ username: 'user' }).then((user) => {
return user.update({ username: 'person', foo: 'bar'}).then((user) => {
return this.User.create({ username: 'user' }).then(user => {
return user.update({ username: 'person', foo: 'bar'}).then(user => {
expect(user.username).to.equal('person');
expect(user.foo).not.to.exist;
});
......@@ -399,7 +399,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
name: 'foobar',
createdAt: new Date(2000, 1, 1),
identifier: 'another identifier'
}).then((user) => {
}).then(user => {
expect(new Date(user.createdAt)).to.equalDate(new Date(oldCreatedAt));
expect(new Date(user.updatedAt)).to.not.equalTime(new Date(oldUpdatedAt));
expect(user.identifier).to.equal(oldIdentifier);
......@@ -417,22 +417,22 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
return Download.sync().then(() => {
return Download.create({
startedAt: new Date()
}).then((download) => {
}).then(download => {
expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt).to.not.be.ok;
expect(download.finishedAt).to.not.be.ok;
return download.update({
canceledAt: new Date()
}).then((download) => {
}).then(download => {
expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt instanceof Date).to.be.true;
expect(download.finishedAt).to.not.be.ok;
return Download.findAll({
where: {finishedAt: null}
}).then((downloads) => {
downloads.forEach((download) => {
}).then(downloads => {
downloads.forEach(download => {
expect(download.startedAt instanceof Date).to.be.true;
expect(download.canceledAt instanceof Date).to.be.true;
expect(download.finishedAt).to.not.be.ok;
......@@ -446,7 +446,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
it('should support logging', function() {
const spy = sinon.spy();
return this.User.create({}).then((user) => {
return this.User.create({}).then(user => {
return user.update({username: 'yolo'}, {logging: spy}).then(() => {
expect(spy.called).to.be.ok;
});
......
......@@ -117,7 +117,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
}, {timestamps: false});
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,
// 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');
......@@ -313,7 +313,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
});
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']);
});
});
......@@ -439,7 +439,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
});
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()).not.to.be.ok;
});
......@@ -485,7 +485,7 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
});
let changed;
User.afterUpdate((instance) => {
User.afterUpdate(instance => {
changed = instance.changed();
return;
});
......@@ -494,11 +494,11 @@ describe(Support.getTestDialectTeaser('DAO'), () => {
return User.create({
name: 'Ford Prefect'
});
}).then((user) => {
}).then(user => {
return user.update({
name: 'Arthur Dent'
});
}).then((user) => {
}).then(user => {
expect(changed).to.be.ok;
expect(changed.length).to.be.ok;
expect(changed.indexOf('name') > -1).to.be.ok;
......
......@@ -54,7 +54,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return student.addCourse(course, { through: {score: 98, test_value: 1000}});
}).then(() => {
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);
});
})
......
......@@ -174,14 +174,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this
.ModelUnderTest
.describe()
.then((fields) => {
.then(fields => {
expect(fields.identifier).to.include({ allowNull: false });
});
});
});
it('should support instance.destroy()', function() {
return this.User.create().then((user) => {
return this.User.create().then(user => {
return user.destroy();
});
});
......@@ -206,32 +206,32 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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[1].notes).to.equal('Number two');
});
});
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[0].notes).to.equal('Number one');
});
});
it('reload should work', function() {
return this.Comment.findById(1).then((comment) => {
return this.Comment.findById(1).then(comment => {
return comment.reload();
});
});
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';
return comment.save();
}).then((comment) => {
}).then(comment => {
return comment.reload();
}).then((comment) => {
}).then(comment => {
expect(comment.notes).to.equal('new note');
});
});
......@@ -275,7 +275,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.User.find({
limit: 1
});
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('Foobar');
return user.updateAttributes({
name: 'Barfoo'
......@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.User.find({
limit: 1
});
}).then((user) => {
}).then(user => {
expect(user.get('name')).to.equal('Barfoo');
});
});
......@@ -306,7 +306,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
where: {
strField: 'bar'
}
}).then((entity) => {
}).then(entity => {
expect(entity).to.be.ok;
expect(entity.get('strField')).to.equal('bar');
});
......@@ -336,7 +336,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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_id')).to.be.an('undefined');
});
......@@ -346,7 +346,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should make the aliased auto incremented primary key available after create', function() {
return this.User.create({
name: 'Barfoo'
}).then((user) => {
}).then(user => {
expect(user.get('id')).to.be.ok;
});
});
......@@ -356,11 +356,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.create({
name: 'Barfoo'
}).then((user) => {
}).then(user => {
return user.createTask({
title: 'DatDo'
});
}).then((task) => {
}).then(task => {
return task.createComment({
text: 'Comment'
});
......@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
],
where: {title: 'DatDo'}
});
}).then((task) => {
}).then(task => {
expect(task.get('title')).to.equal('DatDo');
expect(task.get('comments')[0].get('text')).to.equal('Comment');
expect(task.get('user')).to.be.ok;
......@@ -384,11 +384,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.create({
name: 'Foobar'
}).then((user) => {
}).then(user => {
return user.createTask({
title: 'DoDat'
});
}).then((task) => {
}).then(task => {
return task.createComment({
text: 'Comment'
});
......@@ -400,8 +400,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
]}
]
});
}).then((users) => {
users.forEach((user) => {
}).then(users => {
users.forEach(user => {
expect(user.get('name')).to.be.ok;
expect(user.get('tasks')[0].get('title')).to.equal('DoDat');
expect(user.get('tasks')[0].get('comments')).to.be.ok;
......@@ -410,7 +410,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
it('should work with increment', function() {
return this.User.create().then((user) => {
return this.User.create().then(user => {
return user.increment('taskCount');
});
});
......@@ -426,7 +426,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Foobar'
}
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -444,7 +444,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Lollerskates'
})
});
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
});
});
......@@ -459,8 +459,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
name: 'Cde'
}]).then(() => {
return self.User.findAll();
}).then((users) => {
users.forEach((user) => {
}).then(users => {
users.forEach(user => {
expect(['Abc', 'Bcd', 'Cde'].indexOf(user.get('name')) !== -1).to.be.true;
});
});
......@@ -491,7 +491,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
attributes: findAttributes
});
}).then((tests) => {
}).then(tests => {
expect(tests[0].get('someProperty')).to.be.ok;
expect(tests[0].get('someProperty2')).to.be.ok;
});
......@@ -511,7 +511,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
.then(() => {
return this.User.find({ where: { name: 'test user' } });
})
.then((user) => {
.then(user => {
expect(user.name).to.equal('test user');
});
});
......@@ -525,7 +525,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.Comment.find({
limit: 1
});
}).then((comment) => {
}).then(comment => {
expect(comment.get('notes')).to.equal('Foobar');
return comment.updateAttributes({
notes: 'Barfoo'
......@@ -534,7 +534,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.Comment.find({
limit: 1
});
}).then((comment) => {
}).then(comment => {
expect(comment.get('notes')).to.equal('Barfoo');
});
});
......@@ -573,14 +573,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
.then(() => {
return User.create();
})
.then((user) => {
.then(user => {
return user.destroy();
})
.then(function() {
this.clock.tick(1000);
return User.findAll();
})
.then((users) => {
.then(users => {
expect(users.length).to.equal(0);
});
});
......@@ -597,10 +597,10 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
return User.sync({force: true}).then(() => {
return User.create().then((user) => {
return User.create().then(user => {
return User.destroy({where: {id: user.get('id')}});
}).then(() => {
return User.findAll().then((users) => {
return User.findAll().then(users => {
expect(users.length).to.equal(0);
});
});
......
......@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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);
});
});
......@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
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;
});
......@@ -115,7 +115,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be ignored in create and updateAttributes', function() {
return this.User.create({
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
expect(user.virtualWithDefault).to.equal('cake');
......@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}, {
fields: ['storage']
});
}).then((user) => {
}).then(user => {
expect(user.virtualWithDefault).to.equal('cake');
expect(user.storage).to.equal('something else');
});
......@@ -139,7 +139,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
logging: this.sqlAssert
}).then(() => {
return self.User.findAll();
}).then((users) => {
}).then(users => {
expect(users[0].storage).to.equal('something');
});
});
......
......@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
{username: 'boo2'}
]).then(() => {
return self.User.findOne();
}).then((user) => {
}).then(user => {
return user.createProject({
name: 'project1'
});
......@@ -62,7 +62,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
group: ['createdAt']
})
)
.then((users) => {
.then(users => {
expect(users.length).to.be.eql(2);
// have attributes
......@@ -87,20 +87,20 @@ describe(Support.getTestDialectTeaser('Model'), () => {
order: ['age']
})
)
.then((result) => {
.then(result => {
expect(parseInt(result[0].count)).to.be.eql(2);
return this.User.count({
where: { username: 'fire' }
});
})
.then((count) => {
.then(count => {
expect(count).to.be.eql(0);
return this.User.count({
where: { username: 'fire' },
group: 'age'
});
})
.then((count) => {
.then(count => {
expect(count).to.be.eql([]);
});
});
......@@ -119,14 +119,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
col: 'username'
})
)
.then((count) => {
.then(count => {
expect(parseInt(count)).to.be.eql(3);
return this.User.count({
col: 'age',
distinct: true
});
})
.then((count) => {
.then(count => {
expect(parseInt(count)).to.be.eql(2);
});
});
......@@ -139,11 +139,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
'$Projects.name$': 'project1'
}
};
return this.User.count(queryObject).then((count) => {
return this.User.count(queryObject).then(count => {
expect(parseInt(count)).to.be.eql(1);
queryObject.where['$Projects.name$'] = 'project2';
return this.User.count(queryObject);
}).then((count) => {
}).then(count => {
expect(parseInt(count)).to.be.eql(0);
});
});
......@@ -161,14 +161,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
distinct: true,
include: [this.Project]
})
).then((count) => {
).then(count => {
expect(parseInt(count)).to.be.eql(3);
return this.User.count({
col: 'age',
distinct: true,
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'), () => {
model: User,
myOption: 'option'
}]
}).then((savedProduct) => {
}).then(savedProduct => {
expect(savedProduct.isIncludeCreatedOnAfterCreate).to.be.true;
expect(savedProduct.User.createOptions.myOption).to.be.equal('option');
expect(savedProduct.User.createOptions.parentRecord).to.be.equal(savedProduct);
return Product.findOne({
where: { id: savedProduct.id },
include: [ User ]
}).then((persistedProduct) => {
}).then(persistedProduct => {
expect(persistedProduct.User).to.be.ok;
expect(persistedProduct.User.first_name).to.be.equal('Mick');
expect(persistedProduct.User.last_name).to.be.equal('Broadstone');
......@@ -80,11 +80,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}, {
include: [ Creator ]
}).then((savedProduct) => {
}).then(savedProduct => {
return Product.findOne({
where: { id: savedProduct.id },
include: [ Creator ]
}).then((persistedProduct) => {
}).then(persistedProduct => {
expect(persistedProduct.creator).to.be.ok;
expect(persistedProduct.creator.first_name).to.be.equal('Matt');
expect(persistedProduct.creator.last_name).to.be.equal('Hansen');
......@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
hooks: {
afterCreate(product) {
product.areIncludesCreatedOnAfterCreate = product.Tags &&
product.Tags.every((tag) => {
product.Tags.every(tag => {
return !!tag.id;
});
}
......@@ -131,7 +131,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: Tag,
myOption: 'option'
}]
}).then((savedProduct) => {
}).then(savedProduct => {
expect(savedProduct.areIncludesCreatedOnAfterCreate).to.be.true;
expect(savedProduct.Tags[0].createOptions.myOption).to.be.equal('option');
expect(savedProduct.Tags[0].createOptions.parentRecord).to.be.equal(savedProduct);
......@@ -140,7 +140,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Product.find({
where: { id: savedProduct.id },
include: [ Tag ]
}).then((persistedProduct) => {
}).then(persistedProduct => {
expect(persistedProduct.Tags).to.be.ok;
expect(persistedProduct.Tags.length).to.equal(2);
});
......@@ -168,11 +168,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
]
}, {
include: [ Categories ]
}).then((savedProduct) => {
}).then(savedProduct => {
return Product.find({
where: { id: savedProduct.id },
include: [ Categories ]
}).then((persistedProduct) => {
}).then(persistedProduct => {
expect(persistedProduct.categories).to.be.ok;
expect(persistedProduct.categories.length).to.equal(2);
});
......@@ -199,11 +199,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}, {
include: [ Task ]
}).then((savedUser) => {
}).then(savedUser => {
return User.find({
where: { id: savedUser.id },
include: [ Task ]
}).then((persistedUser) => {
}).then(persistedUser => {
expect(persistedUser.Task).to.be.ok;
});
});
......@@ -230,11 +230,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
}, {
include: [ Job ]
}).then((savedUser) => {
}).then(savedUser => {
return User.find({
where: { id: savedUser.id },
include: [ Job ]
}).then((persistedUser) => {
}).then(persistedUser => {
expect(persistedUser.job).to.be.ok;
});
});
......@@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
hooks: {
afterCreate(user) {
user.areIncludesCreatedOnAfterCreate = user.Tasks &&
user.Tasks.every((task) => {
user.Tasks.every(task => {
return !!task.id;
});
}
......@@ -281,7 +281,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: Task,
myOption: 'option'
}]
}).then((savedUser) => {
}).then(savedUser => {
expect(savedUser.areIncludesCreatedOnAfterCreate).to.be.true;
expect(savedUser.Tasks[0].createOptions.myOption).to.be.equal('option');
expect(savedUser.Tasks[0].createOptions.parentRecord).to.be.equal(savedUser);
......@@ -290,7 +290,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.find({
where: { id: savedUser.id },
include: [ Task ]
}).then((persistedUser) => {
}).then(persistedUser => {
expect(persistedUser.Tasks).to.be.ok;
expect(persistedUser.Tasks.length).to.equal(2);
});
......@@ -378,18 +378,18 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}]
}
);
}).then((savedPost) => {
}).then(savedPost => {
// The saved post should include the two tags
expect(savedPost.tags.length).to.equal(2);
// The saved post should be able to retrieve the two tags
// using the convenience accessor methods
return savedPost.getTags();
}).then((savedTags) => {
}).then(savedTags => {
// All nested tags should be returned
expect(savedTags.length).to.equal(2);
}).then(() => {
return ItemTag.findAll();
}).then((itemTags) => {
}).then(itemTags => {
// Two "through" models should be created
expect(itemTags.length).to.equal(2);
// And their polymorphic field should be correctly set to 'post'
......@@ -420,11 +420,11 @@ describe(Support.getTestDialectTeaser('Model'), () => {
]
}, {
include: [ Jobs ]
}).then((savedUser) => {
}).then(savedUser => {
return User.find({
where: { id: savedUser.id },
include: [ Jobs ]
}).then((persistedUser) => {
}).then(persistedUser => {
expect(persistedUser.jobs).to.be.ok;
expect(persistedUser.jobs.length).to.equal(2);
});
......
......@@ -46,7 +46,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
],
group: [ 'Post.id' ]
});
}).then((posts) => {
}).then(posts => {
expect(parseInt(posts[0].get('comment_count'))).to.be.equal(3);
expect(parseInt(posts[1].get('comment_count'))).to.be.equal(2);
});
......
......@@ -26,9 +26,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should work with order: literal()', function() {
return this.User.findAll({
order: this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.get('email')).to.be.ok;
});
});
......@@ -37,9 +37,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should work with order: [literal()]', function() {
return this.User.findAll({
order: [this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))]
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.get('email')).to.be.ok;
});
});
......@@ -50,9 +50,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
order: [
[this.sequelize.literal('email = ' + this.sequelize.escape('test@sequelizejs.com'))]
]
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
users.forEach((user) => {
users.forEach(user => {
expect(user.get('email')).to.be.ok;
});
});
......
......@@ -27,7 +27,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Pub.sync({ force: true }).then(() => {
return Pub.create({location: point});
}).then((pub) => {
}).then(pub => {
expect(pub).not.to.be.null;
expect(pub.location).to.be.deep.eql(point);
});
......@@ -37,7 +37,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geography).to.be.deep.eql(point);
});
......@@ -53,7 +53,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geography).to.be.deep.eql(point2);
});
});
......@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geography).to.be.deep.eql(point);
});
......@@ -89,7 +89,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geography).to.be.deep.eql(point2);
});
});
......@@ -109,7 +109,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geography).to.be.deep.eql(point);
});
......@@ -125,7 +125,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geography).to.be.deep.eql(point2);
});
});
......@@ -148,7 +148,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
[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.geography).to.be.deep.eql(point);
});
......@@ -170,7 +170,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geography: polygon2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geography).to.be.deep.eql(polygon2);
});
});
......
......@@ -29,7 +29,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Pub.sync({ force: true }).then(() => {
return Pub.create({location: point});
}).then((pub) => {
}).then(pub => {
expect(pub).not.to.be.null;
expect(pub.location).to.be.deep.eql(point);
});
......@@ -39,7 +39,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geometry).to.be.deep.eql(point);
});
......@@ -55,7 +55,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geometry).to.be.deep.eql(point2);
});
});
......@@ -75,7 +75,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geometry).to.be.deep.eql(point);
});
......@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geometry).to.be.deep.eql(point2);
});
});
......@@ -111,7 +111,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const User = this.User;
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.geometry).to.be.deep.eql(point);
});
......@@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: point2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geometry).to.be.deep.eql(point2);
});
});
......@@ -150,7 +150,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
[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.geometry).to.be.deep.eql(point);
});
......@@ -172,7 +172,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return User.update({geometry: polygon2}, {where: {username: props.username}});
}).then(() => {
return User.findOne({where: {username: props.username}});
}).then((user) => {
}).then(user => {
expect(user.geometry).to.be.deep.eql(polygon2);
});
});
......
......@@ -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({
data: {
name: {
......
......@@ -35,24 +35,24 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Account.sync({force: true})
.then(() => Account.create({ ownerId: 12 }))
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }})
.then((result) => {
.then(result => {
expect(result).to.be.equal(1);
});
})
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(0);
return Account.count({ paranoid: false });
})
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
return Account.restore({ where: { ownerId: 12 }});
})
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
});
});
......@@ -83,21 +83,21 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Account.sync({force: true})
.then(() => Account.create({ ownerId: 12 }))
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
return Account.destroy({ where: { ownerId: 12 }});
})
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(0);
return Account.count({ paranoid: false });
})
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
return Account.restore({ where: { ownerId: 12 }});
})
.then(() => Account.count())
.then((count) => {
.then(count => {
expect(count).to.be.equal(1);
});
});
......
......@@ -82,15 +82,15 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantOne.findOne({
where: {foo: 'one'}
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one');
restaurantId = obj.id;
return self.RestaurantOne.findById(restaurantId);
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
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;
});
});
......@@ -107,15 +107,15 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantTwo.findOne({
where: {foo: 'two'}
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.foo).to.equal('two');
restaurantId = obj.id;
return self.RestaurantTwo.findById(restaurantId);
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
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;
});
});
......@@ -145,59 +145,59 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return restaurauntModel.save();
}).then(() => {
return self.RestaurantOne.findAll();
}).then((restaurantsOne) => {
}).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(2);
restaurantsOne.forEach((restaurant) => {
restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one');
});
return self.RestaurantOne.findAndCountAll();
}).then((restaurantsOne) => {
}).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.rows.length).to.equal(2);
expect(restaurantsOne.count).to.equal(2);
restaurantsOne.rows.forEach((restaurant) => {
restaurantsOne.rows.forEach(restaurant => {
expect(restaurant.bar).to.contain('one');
});
return self.RestaurantOne.findAll({
where: {bar: {$like: '%.1'}}
});
}).then((restaurantsOne) => {
}).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(1);
restaurantsOne.forEach((restaurant) => {
restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one');
});
return self.RestaurantOne.count();
}).then((count) => {
}).then(count => {
expect(count).to.not.be.null;
expect(count).to.equal(2);
return self.RestaurantTwo.findAll();
}).then((restaurantsTwo) => {
}).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(3);
restaurantsTwo.forEach((restaurant) => {
restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two');
});
return self.RestaurantTwo.findAndCountAll();
}).then((restaurantsTwo) => {
}).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.rows.length).to.equal(3);
expect(restaurantsTwo.count).to.equal(3);
restaurantsTwo.rows.forEach((restaurant) => {
restaurantsTwo.rows.forEach(restaurant => {
expect(restaurant.bar).to.contain('two');
});
return self.RestaurantTwo.findAll({
where: {bar: {$like: '%.3'}}
});
}).then((restaurantsTwo) => {
}).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(1);
restaurantsTwo.forEach((restaurant) => {
restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two');
});
return self.RestaurantTwo.count();
}).then((count) => {
}).then(count => {
expect(count).to.not.be.null;
expect(count).to.equal(3);
});
......@@ -211,14 +211,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return Location.sync({force: true})
.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.name).to.equal('HQ');
locationId = obj.id;
});
});
})
.catch((err) => {
.catch(err => {
expect(err).to.be.null;
});
});
......@@ -235,7 +235,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.Location, as: 'location'
}]
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one');
expect(obj.location).to.not.be.null;
......@@ -264,7 +264,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantOne.findOne({
where: {foo: 'one'}
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.foo).to.equal('one');
restaurantId = obj.id;
......@@ -279,13 +279,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.EmployeeOne, as: 'employees'
}]
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.employees).to.not.be.null;
expect(obj.employees.length).to.equal(1);
expect(obj.employees[0].last_name).to.equal('one');
return obj.getEmployees({schema:SCHEMA_ONE});
}).then((employees) => {
}).then(employees => {
expect(employees.length).to.equal(1);
expect(employees[0].last_name).to.equal('one');
return self.EmployeeOne.findOne({
......@@ -293,12 +293,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.RestaurantOne, as: 'restaurant'
}]
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.restaurant).to.not.be.null;
expect(obj.restaurant.foo).to.equal('one');
return obj.getRestaurant({schema:SCHEMA_ONE});
}).then((restaurant) => {
}).then(restaurant => {
expect(restaurant).to.not.be.null;
expect(restaurant.foo).to.equal('one');
});
......@@ -315,7 +315,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return self.RestaurantTwo.findOne({
where: {foo: 'two'}
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.foo).to.equal('two');
restaurantId = obj.id;
......@@ -330,13 +330,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.Employee.schema(SCHEMA_TWO), as: 'employees'
}]
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.employees).to.not.be.null;
expect(obj.employees.length).to.equal(1);
expect(obj.employees[0].last_name).to.equal('two');
return obj.getEmployees({schema:SCHEMA_TWO});
}).then((employees) => {
}).then(employees => {
expect(employees.length).to.equal(1);
expect(employees[0].last_name).to.equal('two');
return self.Employee.schema(SCHEMA_TWO).findOne({
......@@ -344,12 +344,12 @@ describe(Support.getTestDialectTeaser('Model'), () => {
model: self.RestaurantTwo, as: 'restaurant'
}]
});
}).then((obj) => {
}).then(obj => {
expect(obj).to.not.be.null;
expect(obj.restaurant).to.not.be.null;
expect(obj.restaurant.foo).to.equal('two');
return obj.getRestaurant({schema:SCHEMA_TWO});
}).then((restaurant) => {
}).then(restaurant => {
expect(restaurant).to.not.be.null;
expect(restaurant.foo).to.equal('two');
});
......@@ -371,17 +371,17 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return restaurauntModelSchema1.save();
}).then(() => {
return Restaurant.schema(SCHEMA_ONE).findAll();
}).then((restaurantsOne) => {
}).then(restaurantsOne => {
expect(restaurantsOne).to.not.be.null;
expect(restaurantsOne.length).to.equal(2);
restaurantsOne.forEach((restaurant) => {
restaurantsOne.forEach(restaurant => {
expect(restaurant.bar).to.contain('one');
});
return Restaurant.schema(SCHEMA_TWO).findAll();
}).then((restaurantsTwo) => {
}).then(restaurantsTwo => {
expect(restaurantsTwo).to.not.be.null;
expect(restaurantsTwo.length).to.equal(1);
restaurantsTwo.forEach((restaurant) => {
restaurantsTwo.forEach(restaurant => {
expect(restaurant.bar).to.contain('two');
});
});
......
......@@ -42,7 +42,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to merge attributes as array', function() {
return this.ScopeMe.scope('lowAccess', 'withName').findOne()
.then((record) => {
.then(record => {
expect(record.other_value).to.exist;
expect(record.username).to.exist;
expect(record.access_level).to.exist;
......
......@@ -60,7 +60,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.ScopeMe.bulkCreate(records);
}).then(() => {
return this.ScopeMe.findAll();
}).then((records) => {
}).then(records => {
return Promise.all([
records[0].createChild({
priority: 1
......
......@@ -126,7 +126,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply default scope when including an associations', function() {
return this.Company.findAll({
include: [this.UserAssociation]
}).get(0).then((company) => {
}).get(0).then(company => {
expect(company.users).to.have.length(2);
});
});
......@@ -134,7 +134,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply default scope when including a model', function() {
return this.Company.findAll({
include: [{ model: this.ScopeMe, as: 'users'}]
}).get(0).then((company) => {
}).get(0).then(company => {
expect(company.users).to.have.length(2);
});
});
......@@ -142,7 +142,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to include a scoped model', function() {
return this.Company.findAll({
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[0].get('username')).to.equal('tony');
});
......@@ -161,9 +161,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should be able to unscope', () => {
it('hasMany', function() {
return this.Company.findById(1).then((company) => {
return this.Company.findById(1).then(company => {
return company.getUsers({ scope: false});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(4);
});
});
......@@ -174,25 +174,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1
}).bind(this).then(function() {
return this.ScopeMe.findById(1);
}).then((user) => {
}).then(user => {
return user.getProfile({ scope: false });
}).then((profile) => {
}).then(profile => {
expect(profile).to.be.ok;
});
});
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 });
}).then((company) => {
}).then(company => {
expect(company).to.be.ok;
});
});
it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => {
return this.Project.findAll().get(0).then(p => {
return p.getCompanies({ scope: false});
}).then((companies) => {
}).then(companies => {
expect(companies).to.have.length(2);
});
});
......@@ -200,9 +200,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should apply default scope', () => {
it('hasMany', function() {
return this.Company.findById(1).then((company) => {
return this.Company.findById(1).then(company => {
return company.getUsers();
}).then((users) => {
}).then(users => {
expect(users).to.have.length(2);
});
});
......@@ -213,25 +213,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1
}).bind(this).then(function() {
return this.ScopeMe.findById(1);
}).then((user) => {
}).then(user => {
return user.getProfile();
}).then((profile) => {
}).then(profile => {
expect(profile).not.to.be.ok;
});
});
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();
}).then((company) => {
}).then(company => {
expect(company).not.to.be.ok;
});
});
it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => {
return this.Project.findAll().get(0).then(p => {
return p.getCompanies();
}).then((companies) => {
}).then(companies => {
expect(companies).to.have.length(1);
expect(companies[0].get('active')).to.be.ok;
});
......@@ -240,9 +240,9 @@ describe(Support.getTestDialectTeaser('Model'), () => {
describe('it should be able to apply another scope', () => {
it('hasMany', function() {
return this.Company.findById(1).then((company) => {
return this.Company.findById(1).then(company => {
return company.getUsers({ scope: 'isTony'});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(1);
expect(users[0].get('username')).to.equal('tony');
});
......@@ -254,25 +254,25 @@ describe(Support.getTestDialectTeaser('Model'), () => {
userId: 1
}).bind(this).then(function() {
return this.ScopeMe.findById(1);
}).then((user) => {
}).then(user => {
return user.getProfile({ scope: 'notActive' });
}).then((profile) => {
}).then(profile => {
expect(profile).not.to.be.ok;
});
});
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' });
}).then((company) => {
}).then(company => {
expect(company).to.be.ok;
});
});
it('belongsToMany', function() {
return this.Project.findAll().get(0).then((p) => {
return this.Project.findAll().get(0).then(p => {
return p.getCompanies({ scope: 'reversed' });
}).then((companies) => {
}).then(companies => {
expect(companies).to.have.length(2);
expect(companies[0].id).to.equal(2);
expect(companies[1].id).to.equal(1);
......@@ -297,7 +297,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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);
});
});
......
......@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.ScopeMe.bulkCreate(records);
}).then(() => {
return this.ScopeMe.findAll();
}).then((records) => {
}).then(records => {
return Promise.all([
records[0].createChild({
priority: 1
......
......@@ -47,7 +47,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply defaultScope', function() {
return this.ScopeMe.destroy({ where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll();
}).then((users) => {
}).then(users => {
expect(users).to.have.length(2);
expect(users[0].get('username')).to.equal('tony');
expect(users[1].get('username')).to.equal('fred');
......@@ -57,7 +57,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
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.unscoped().findAll();
}).then((users) => {
}).then(users => {
expect(users).to.have.length(2);
expect(users[0].get('username')).to.equal('tobi');
expect(users[1].get('username')).to.equal('dan');
......@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to apply other scopes', function() {
return this.ScopeMe.scope('lowAccess').destroy({ where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll();
}).then((users) => {
}).then(users => {
expect(users).to.have.length(1);
expect(users[0].get('username')).to.equal('tobi');
});
......@@ -82,7 +82,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
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.unscoped().findAll();
}).then((users) => {
}).then(users => {
expect(users).to.have.length(3);
expect(users[0].get('username')).to.equal('tony');
expect(users[1].get('username')).to.equal('tobi');
......
......@@ -57,14 +57,14 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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[0].username).to.equal('tobi');
});
});
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(['tony', 'fred'].indexOf(users[0].username) !== -1).to.be.true;
expect(['tony', 'fred'].indexOf(users[1].username) !== -1).to.be.true;
......@@ -72,7 +72,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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([10, 5].indexOf(users[0].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'), () => {
});
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[0].username).to.equal('tony');
});
......@@ -94,7 +94,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(users).to.have.length(1);
return this.ScopeMe.findAll();
}).then((users) => {
}).then(users => {
// This should not have other_value: 10
expect(users).to.have.length(2);
});
......@@ -106,7 +106,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(users).to.have.length(1);
return this.ScopeMe.scope('highValue').findAll();
}).then((users) => {
}).then(users => {
// This should not have other_value: 10
expect(users).to.have.length(2);
});
......@@ -114,7 +114,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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');
});
});
......
......@@ -51,7 +51,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
});
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.rows.length).to.equal(2);
});
......@@ -59,7 +59,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to override default scope', function() {
return this.ScopeMe.findAndCount({ where: { access_level: { gt: 5 }}})
.then((result) => {
.then(result => {
expect(result.count).to.equal(1);
expect(result.rows.length).to.equal(1);
});
......@@ -67,7 +67,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to unscope', function() {
return this.ScopeMe.unscoped().findAndCount({ limit: 1 })
.then((result) => {
.then(result => {
expect(result.count).to.equal(4);
expect(result.rows.length).to.equal(1);
});
......@@ -75,21 +75,21 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to apply other scopes', function() {
return this.ScopeMe.scope('lowAccess').findAndCount()
.then((result) => {
.then(result => {
expect(result.count).to.equal(3);
});
});
it('should be able to merge scopes with where', function() {
return this.ScopeMe.scope('lowAccess')
.findAndCount({ where: { username: 'dan'}}).then((result) => {
.findAndCount({ where: { username: 'dan'}}).then(result => {
expect(result.count).to.equal(1);
});
});
it('should ignore the order option if it is found within the scope', function() {
return this.ScopeMe.scope('withOrder').findAndCount()
.then((result) => {
.then(result => {
expect(result.count).to.equal(4);
});
});
......
......@@ -48,7 +48,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should apply defaultScope', function() {
return this.ScopeMe.update({ username: 'ruben' }, { where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(2);
expect(users[0].get('email')).to.equal('tobi@fakeemail.com');
expect(users[1].get('email')).to.equal('dan@sequelizejs.com');
......@@ -58,7 +58,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
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.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(2);
expect(users[0].get('email')).to.equal('tony@sequelizejs.com');
expect(users[1].get('email')).to.equal('fred@foobar.com');
......@@ -68,8 +68,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
it('should be able to unscope destroy', function() {
return this.ScopeMe.unscoped().update({ username: 'ruben' }, { where: {}}).bind(this).then(function() {
return this.ScopeMe.unscoped().findAll();
}).then((rubens) => {
expect(_.every(rubens, (r) => {
}).then(rubens => {
expect(_.every(rubens, r => {
return r.get('username') === 'ruben';
})).to.be.true;
});
......@@ -78,7 +78,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
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.unscoped().findAll({ where: { username: { $ne: 'ruben' }}});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(1);
expect(users[0].get('email')).to.equal('tobi@fakeemail.com');
});
......@@ -87,7 +87,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
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.unscoped().findAll({ where: { username: 'ruben' }});
}).then((users) => {
}).then(users => {
expect(users).to.have.length(1);
expect(users[0].get('email')).to.equal('dan@sequelizejs.com');
});
......
......@@ -74,7 +74,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return this.User.findById(42);
}).then((user) => {
}).then(user => {
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
......@@ -99,7 +99,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return this.User.find({ where: { foo: 'baz', bar: 19 }});
}).then((user) => {
}).then(user => {
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
......@@ -158,7 +158,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
this.clock.tick(1000);
// Update the first one
return User.upsert({ a: 'a', b: 'b', username: 'doe' });
}).then((created) => {
}).then(created => {
if (dialect === 'sqlite') {
expect(created).to.be.undefined;
} else {
......@@ -166,13 +166,13 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return User.find({ where: { a: 'a', b: 'b' }});
}).then((user1) => {
}).then(user1 => {
expect(user1.createdAt).to.be.ok;
expect(user1.username).to.equal('doe');
expect(user1.updatedAt).to.be.afterTime(user1.createdAt);
return User.find({ where: { a: 'a', b: 'a' }});
}).then((user2) => {
}).then(user2 => {
// The second one should not be updated
expect(user2.createdAt).to.be.ok;
expect(user2.username).to.equal('curt');
......@@ -212,7 +212,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return this.User.findById(42);
}).then((user) => {
}).then(user => {
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.blob.toString()).to.equal('andrea');
......@@ -237,7 +237,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return this.User.findById(42);
}).then((user) => {
}).then(user => {
expect(user.baz).to.equal('oof');
});
});
......@@ -261,7 +261,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
return this.ModelWithFieldPK.findOne({ where: { userId: 42 } });
}).then((instance) => {
}).then(instance => {
expect(instance.foo).to.equal('second');
});
});
......@@ -284,7 +284,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
expect(created).not.to.be.ok;
}
return this.User.findById(42);
}).then((user) => {
}).then(user => {
expect(user.createdAt).to.be.ok;
expect(user.username).to.equal('doe');
expect(user.foo).to.equal('MIXEDCASE2');
......@@ -304,7 +304,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.upsert({ id: 42, username: 'doe'});
}).then(function() {
return this.User.findById(42);
}).then((user) => {
}).then(user => {
expect(user.updatedAt).to.be.gt(originalUpdatedAt);
expect(user.createdAt).to.deep.equal(originalCreatedAt);
clock.restore();
......@@ -322,7 +322,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.upsert({ id: 42, username: 'doe'});
}).then(function() {
return this.User.findById(42);
}).then((user) => {
}).then(user => {
// 'username' was updated
expect(user.username).to.equal('doe');
// 'baz' should still be 'new baz value' since it was not updated
......@@ -335,7 +335,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return this.User.findById(42);
}).then(function(user) {
return this.User.upsert({ id: user.id, username: user.username });
}).then((created) => {
}).then(created => {
if (dialect === 'sqlite') {
expect(created).to.be.undefined;
} else {
......@@ -364,7 +364,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
const clock = sinon.useFakeTimers();
return User.sync({ force: true }).bind(this).then(() => {
return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'City' })
.then((created) => {
.then(created => {
if (dialect === 'sqlite') {
expect(created).to.be.undefined;
} else {
......@@ -372,7 +372,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
}
clock.tick(1000);
return User.upsert({ username: 'user1', email: 'user1@domain.ext', city: 'New City' });
}).then((created) => {
}).then(created => {
if (dialect === 'sqlite') {
expect(created).to.be.undefined;
} else {
......@@ -381,7 +381,7 @@ describe(Support.getTestDialectTeaser('Model'), () => {
clock.tick(1000);
return User.findOne({ where: { username: 'user1', email: 'user1@domain.ext' }});
})
.then((user) => {
.then(user => {
expect(user.createdAt).to.be.ok;
expect(user.city).to.equal('New City');
expect(user.updatedAt).to.be.afterTime(user.createdAt);
......
......@@ -67,14 +67,14 @@ describe(Support.getTestDialectTeaser('Replication'), function() {
});
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});
})
.then(expectReadCalls);
});
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});
})
.then(expectWriteCalls);
......
......@@ -25,22 +25,22 @@ describe(Support.getTestDialectTeaser('Schema'), () => {
});
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 });
}).then((result) => {
}).then(result => {
return result.reload();
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(4);
});
});
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 });
}).then((result) => {
}).then(result => {
return result.reload();
}).then((user) => {
}).then(user => {
expect(user).to.be.ok;
expect(user.aNumber).to.be.equal(7);
});
......
......@@ -24,7 +24,7 @@ if (current.dialect.supports.transactions) {
let called = false;
return this
.sequelize
.transaction().then((t) => {
.transaction().then(t => {
return t.commit().then(() => {
called = 1;
});
......@@ -38,7 +38,7 @@ if (current.dialect.supports.transactions) {
let called = false;
return this
.sequelize
.transaction().then((t) => {
.transaction().then(t => {
return t.rollback().then(() => {
called = 1;
});
......@@ -86,7 +86,7 @@ if (current.dialect.supports.transactions) {
});
}).then(function() {
return this.User.all();
}).then((users) => {
}).then(users => {
expect(users.length).to.equal(1);
expect(users[0].name).to.equal('foo');
});
......@@ -96,14 +96,14 @@ if (current.dialect.supports.transactions) {
describe('complex long running example', () => {
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', {
id: { type: Support.Sequelize.INTEGER, primaryKey: true, autoIncrement: true},
name: { type: Support.Sequelize.STRING }
});
return sequelize.sync({ force: true }).then(() => {
return sequelize.transaction().then((transaction) => {
return sequelize.transaction().then(transaction => {
expect(transaction).to.be.instanceOf(Transaction);
return Test
......@@ -113,7 +113,7 @@ if (current.dialect.supports.transactions) {
return transaction
.commit()
.then(() => { return Test.count(); })
.then((count) => {
.then(count => {
expect(count).to.equal(1);
});
});
......@@ -129,7 +129,7 @@ if (current.dialect.supports.transactions) {
beforeEach(function() {
const self = this;
return Support.prepareTransactionTest(this.sequelize).then((sequelize) => {
return Support.prepareTransactionTest(this.sequelize).then(sequelize => {
self.sequelize = sequelize;
self.Model = sequelize.define('Model', {
......@@ -145,11 +145,11 @@ if (current.dialect.supports.transactions) {
it('triggers the error event for the second transactions', function() {
const self = this;
return this.sequelize.transaction().then((t1) => {
return self.sequelize.transaction().then((t2) => {
return this.sequelize.transaction().then(t1 => {
return self.sequelize.transaction().then(t2 => {
return self.Model.create({ name: 'omnom' }, { transaction: t1 }).then(() => {
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;
return t2.rollback();
}),
......
......@@ -46,10 +46,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
return User.sync({ force: true }).bind(this).then(() => {
return Task.sync({ force: true });
}).then(function() {
return this.sequelize.transaction(transactionOptions, (t) => {
return this.sequelize.transaction(transactionOptions, t => {
return Task
.create({ title: 'a task', user_id: -1 }, { transaction: t })
.then((task) => {
.then(task => {
return [task, User.create({}, { transaction: t })];
})
.spread((task, user) => {
......@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('allows the violation of the foreign key constraint if the transaction is deferred', function() {
return this
.run(Sequelize.Deferrable.INITIALLY_IMMEDIATE)
.then((task) => {
.then(task => {
expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1);
});
......@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
deferrable: Sequelize.Deferrable.SET_DEFERRED([taskTableName + '_user_id_fkey']),
taskTableName
})
.then((task) => {
.then(task => {
expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1);
});
......@@ -102,7 +102,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('allows the violation of the foreign key constraint', function() {
return this
.run(Sequelize.Deferrable.INITIALLY_DEFERRED)
.then((task) => {
.then(task => {
expect(task.title).to.equal('a task');
expect(task.user_id).to.equal(1);
});
......
......@@ -62,7 +62,7 @@ if (dialect !== 'sqlite') {
return this.sequelize.sync({ force: true }).bind(this).then(() => {
return TimezonedUser.create({});
}).then((timezonedUser) => {
}).then(timezonedUser => {
return Promise.all([
NormalUser.findById(timezonedUser.id),
TimezonedUser.findById(timezonedUser.id)
......
......@@ -48,7 +48,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should return output rows after instance update', () => {
return User.create({
username: 'triggertest'
}).then((user) => {
}).then(user => {
user.username = 'usernamechanged';
return user.save();
})
......@@ -60,7 +60,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should return output rows after Model update', () => {
return User.create({
username: 'triggertest'
}).then((user) => {
}).then(user => {
return User.update({
username: 'usernamechanged'
}, {
......@@ -77,7 +77,7 @@ if (current.dialect.supports.tmpTableTrigger) {
it('should successfully delete with a trigger on the table', () => {
return User.create({
username: 'triggertest'
}).then((user) => {
}).then(user => {
return user.destroy();
}).then(() => {
return expect(User.find({username: 'triggertest'})).to.eventually.be.null;
......
......@@ -271,7 +271,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
}
}, type)), 'count-engines-wings']
]
}).spread((airplane) => {
}).spread(airplane => {
expect(parseInt(airplane.get('count'))).to.equal(3);
expect(parseInt(airplane.get('count-engines'))).to.equal(1);
expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2);
......@@ -296,7 +296,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
}
}), 'count-engines-wings']
]
}).spread((airplane) => {
}).spread(airplane => {
expect(parseInt(airplane.get('count'))).to.equal(3);
expect(parseInt(airplane.get('count-engines'))).to.equal(1);
expect(parseInt(airplane.get('count-engines-wings'))).to.equal(2);
......
......@@ -18,10 +18,10 @@ describe(Support.getTestDialectTeaser('Vectors'), () => {
return Student.sync({force: true}).then(() => {
return Student.create({
name: 'Robert\\\'); DROP TABLE "students"; --'
}).then((result) => {
}).then(result => {
expect(result.get('name')).to.equal('Robert\\\'); DROP TABLE "students"; --');
return Student.findAll();
}).then((result) => {
}).then(result => {
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!