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

Commit 17e3daf9 by José Moreira

Cleaning all tests

* all:
  * Removed non used variables.
* test/dao/values.test.js:
  * Changed some lines to dot notation since we aren’t getting from
variables.
1 parent c355fb75
......@@ -6,12 +6,7 @@ var chai = require('chai')
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
chai.config.includeStack = true
......
......@@ -6,12 +6,8 @@ var chai = require('chai')
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
chai.config.includeStack = true
......@@ -35,7 +31,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
describe('findOrCreate', function () {
it("supports transactions", function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('user_with_transaction', { username: Sequelize.STRING, data: Sequelize.STRING })
......@@ -180,7 +175,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
it('supports transactions', function(done) {
var self = this
Support.prepareTransactionTest(this.sequelize, function(sequelize) {
var User = sequelize.define('user_with_transaction', { username: Sequelize.STRING })
......@@ -697,7 +691,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should allow blank creates (with timestamps: false)', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.create({}, {fields: []}).done(function (err, worker) {
expect(err).not.to.be.ok
expect(worker).to.be.ok
......@@ -708,7 +702,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should allow truly blank creates', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.create({}, {fields: []}).done(function (err, worker) {
expect(err).not.to.be.ok
expect(worker).to.be.ok
......@@ -791,7 +785,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
......@@ -803,7 +797,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
......@@ -819,7 +813,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
......@@ -833,14 +827,14 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
Enum.sync({ force: true }).success(function() {
Enum.create({ state: 'happy' }).success(function(_item) {
Enum.create({ state: 'happy' }).success(function() {
done()
});
});
})
})
describe('can safely sync multiple times', function(done) {
describe('can safely sync multiple times', function() {
it('through the factory', function(done) {
var Enum = this.sequelize.define('Enum', {
state: {
......@@ -1095,7 +1089,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should allow blank arrays (return immediatly)', function (done) {
var Worker = this.sequelize.define('Worker', {})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([]).done(function (err, workers) {
expect(err).not.to.be.ok
expect(workers).to.be.ok
......@@ -1107,7 +1101,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should allow blank creates (with timestamps: false)', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([{}, {}]).done(function (err, workers) {
expect(err).not.to.be.ok
expect(workers).to.be.ok
......@@ -1118,7 +1112,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('should allow autoincremented attributes to be set', function (done) {
var Worker = this.sequelize.define('Worker', {}, {timestamps: false})
Worker.sync().done(function(err) {
Worker.sync().done(function() {
Worker.bulkCreate([
{id: 5},
{id: 10}
......
......@@ -5,12 +5,9 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
......@@ -79,7 +76,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('does not modify the passed arguments', function (done) {
var options = { where: ['specialkey = ?', 'awesome']}
this.UserPrimary.find(options).success(function(user) {
this.UserPrimary.find(options).success(function() {
expect(options).to.deep.equal({ where: ['specialkey = ?', 'awesome']})
done()
})
......@@ -101,7 +98,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
xit('doesn\'t throw an error when entering in a non integer value', function(done) {
it.skip('doesn\'t throw an error when entering in a non integer value', function(done) {
this.User.find('a string value').success(function(user) {
expect(user).to.be.null
done()
......@@ -218,7 +215,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
UserPrimary.create({
id: 'a string based id',
name: 'Johnno'
}).success(function(u) {
}).success(function() {
UserPrimary.find('a string based id').success(function(u2) {
expect(u2.id).to.equal('a string based id')
expect(u2.name).to.equal('Johnno')
......@@ -420,8 +417,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.sequelize.sync({ force: true }).success(function() {
User.create({username: 'test_testerson'}).success(function(user) {
Message.create({user_id: user.id, message: 'hi there!'}).success(function(message) {
Message.create({user_id: user.id, message: 'a second message'}).success(function(message) {
Message.create({user_id: user.id, message: 'hi there!'}).success(function() {
Message.create({user_id: user.id, message: 'a second message'}).success(function() {
Message.findAll({
where: {user_id: user.id},
......@@ -546,7 +543,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
done()
})
describe('alias', function(done) {
describe('alias', function() {
beforeEach(function(done) {
var self = this
this.Worker.hasOne(this.Task, { as: 'ToDo' })
......@@ -654,9 +651,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
self.Photo.create({ img: 'img.jpg' }).success(function(somePhoto) {
self.PhoneNumber.create({ phone: '000000' }).success(function(somePhone1) {
self.PhoneNumber.create({ phone: '111111' }).success(function(somePhone2) {
someContact.setPhotos([somePhoto]).complete(function (err, data) {
someContact.setPhotos([somePhoto]).complete(function (err) {
expect(err).to.be.null
someContact.setPhoneNumbers([somePhone1, somePhone2]).complete(function (err, data) {
someContact.setPhoneNumbers([somePhone1, somePhone2]).complete(function () {
self.Contact.find({
where: {
name: 'Boris'
......@@ -698,7 +695,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
self.sequelize.sync({ force: true }).success(function() {
self.User.create({ username: 'someone' }).success(function(someUser) {
self.Group.create({ name: 'people' }).success(function(someGroup) {
someUser.setGroupPKeagerones([someGroup]).complete(function (err, data) {
someUser.setGroupPKeagerones([someGroup]).complete(function (err) {
expect(err).to.be.null
self.User.find({
where: {
......@@ -803,7 +800,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.Product.hasMany(this.Tag, {as: 'Tags', through: 'product_tag'})
this.Tag.hasMany(this.Product, {as: 'Products', through: 'product_tag'})
this.sequelize.sync().done(function (err) {
this.sequelize.sync().done(function () {
async.auto({
createProducts: function (callback) {
self.Product.bulkCreate([
......
......@@ -7,7 +7,6 @@ var chai = require('chai')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
......@@ -62,7 +61,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
describe('special where conditions/smartWhere object', function() {
beforeEach(function(done) {
var self = this
this.buf = new Buffer(16);
this.buf.fill('\x01');
......@@ -70,7 +68,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.User.bulkCreate([
{username: 'boo', intVal: 5, theDate: '2013-01-01 12:00'},
{username: 'boo2', intVal: 10, theDate: '2013-01-10 12:00', binary: this.buf }
]).success(function(user2) {
]).success(function() {
done()
})
})
......@@ -91,7 +89,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
where: {
id: [1, 2, 3]
}
}).success(function(users){
}).success(function(){
done();
});
})
......@@ -1225,7 +1223,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('does not modify the passed arguments', function (done) {
var options = { where: ['username = ?', 'awesome']}
this.User.findAll(options).success(function(user) {
this.User.findAll(options).success(function() {
expect(options).to.deep.equal({ where: ['username = ?', 'awesome']})
done()
})
......
......@@ -5,13 +5,7 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
chai.config.includeStack = true
......
......@@ -156,7 +156,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
// In my opinion this is bad logic, null is different from an empty string
xit("returns false for two empty attributes", function(done) {
it.skip("returns false for two empty attributes", function(done) {
this.User.create({ username: null }).success(function(user) {
user.username = ''
expect(user.isDirty).to.be.false
......
......@@ -4,12 +4,7 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, uuid = require('node-uuid')
, _ = require('lodash')
chai.use(datetime)
chai.config.includeStack = true
......@@ -205,7 +200,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
price: {
type: Sequelize.FLOAT,
get: function() {
return this.dataValues['price'] * 100
return this.dataValues.price * 100
}
}
})
......@@ -224,7 +219,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}, {
getterMethods: {
price: function() {
return this.dataValues['priceInCents'] / 100
return this.dataValues.priceInCents / 100
}
}
})
......@@ -240,7 +235,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
price: {
type: Sequelize.STRING,
get: function() {
return this.dataValues['price'] * 100
return this.dataValues.price * 100
}
}
}, {
......@@ -283,8 +278,6 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
contact.save().done(function(err, me) {
expect(err).not.to.be.ok
var idToTest = me.id;
expect(me.get('tags')).to.deep.equal(['yes', 'no'])
done();
});
......@@ -298,7 +291,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
name: {type: DataTypes.STRING}
})
User.sync().done(function (err) {
User.sync().done(function () {
User.create({name: 'Jan Meier'}).done(function (err, user) {
expect(err).not.to.be.ok
expect(user.changed('name')).to.be.false
......@@ -328,7 +321,7 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
name: {type: DataTypes.STRING}
})
User.sync().done(function (err) {
User.sync().done(function () {
var user = User.build({
name: 'Jan Meier'
})
......
......@@ -5,12 +5,7 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
......@@ -398,7 +393,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user, i) {
users.forEach(function (user) {
user.memberships.sort(sortById)
expect(user.memberships.length).to.equal(2)
......@@ -473,9 +468,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
},
singleChain: function (callback) {
var previousInstance
, previousModel
async.eachSeries(singles, function (model, callback, i) {
async.eachSeries(singles, function (model, callback) {
model.create({}).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
......@@ -666,7 +660,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
Product.findAll({
......@@ -716,7 +710,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
userGroups: ['users', 'groups', function (callback, results) {
results.users[2].setGroup(results.groups[1]).done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -762,7 +756,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.add(results.users[1].setGroup(results.groups[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -809,7 +803,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.add(results.users[1].setGroup(results.groups[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -874,7 +868,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -944,7 +938,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1014,7 +1008,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1066,7 +1060,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.add(results.users[0].setLeaderOf(results.projects[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1132,7 +1126,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
Product.findAll({
......@@ -1361,7 +1355,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.add(results.users[3].setGroup(results.groups[1]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......
......@@ -5,12 +5,7 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
, sinon = require('sinon')
, datetime = require('chai-datetime')
, _ = require('lodash')
, moment = require('moment')
, async = require('async')
chai.use(datetime)
......@@ -125,7 +120,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
{name: 'Admin', canInvite: 1, canRemove: 1, canPost: 1},
{name: 'Trustee', canInvite: 1, canRemove: 0, canPost: 1},
{name: 'Member', canInvite: 1, canRemove: 0, canPost: 0}
]).done(function (err) {
]).done(function () {
Rank.findAll().done(callback)
})
},
......@@ -407,7 +402,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
]
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user, i) {
users.forEach(function (user) {
expect(user.memberships).to.be.ok
user.memberships.sort(sortById)
......@@ -485,9 +480,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
},
singleChain: function (callback) {
var previousInstance
, previousModel
async.eachSeries(singles, function (model, callback, i) {
async.eachSeries(singles, function (model, callback) {
model.create({}).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
......@@ -678,7 +672,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
Product.findAll({
......@@ -728,7 +722,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
userGroups: ['users', 'groups', function (callback, results) {
results.users[2].setGroup(results.groups[1]).done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -774,7 +768,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.add(results.users[1].setGroup(results.groups[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -821,7 +815,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.add(results.users[1].setGroup(results.groups[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -885,7 +879,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -955,7 +949,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1025,7 +1019,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1077,7 +1071,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.add(results.users[0].setLeaderOf(results.projects[0]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1143,7 +1137,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
Product.findAll({
......@@ -1372,7 +1366,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
chainer.add(results.users[3].setGroup(results.groups[1]))
chainer.run().done(callback)
}]
}, function (err, results) {
}, function (err) {
expect(err).not.to.be.ok
User.findAll({
......@@ -1480,7 +1474,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
})
})
xit('should support including date fields, with the correct timeszone', function (done) {
it.skip('should support including date fields, with the correct timeszone', function (done) {
var User = this.sequelize.define('user', {
dateField: Sequelize.DATE
}, {timestamps: false, schema: "account"})
......
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect()
, sinon = require('sinon')
, DataTypes = require(__dirname + "/../../lib/data-types")
chai.config.includeStack = true
......
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect()
, sinon = require('sinon')
, DataTypes = require(__dirname + "/../../lib/data-types")
......
......@@ -3,7 +3,6 @@ var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, dialect = Support.getTestDialect()
, config = require(__dirname + "/../config/config")
chai.config.includeStack = true
......
......@@ -2,8 +2,6 @@
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect()
, util = require("util")
, _ = require('lodash')
, QueryGenerator = require("../../lib/dialects/mysql/query-generator")
......
......@@ -124,7 +124,7 @@ if (dialect === 'sqlite') {
})
})
xit("should make aliased attributes available", function(done) {
it.skip("should make aliased attributes available", function(done) {
this.User.find({ where: { name:'user' }, attributes: ['id', ['name', 'username']] }).success(function(user) {
expect(user.username).to.equal('user')
done()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!