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

Commit 6340df70 by Sohum Banerjea

more tests - correct return, and test for the association pathway

1 parent 1d437cf8
Showing with 57 additions and 0 deletions
...@@ -102,6 +102,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -102,6 +102,9 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
binary: [ this.buf, this.buf ] binary: [ this.buf, this.buf ]
} }
}).success(function(users){ }).success(function(users){
expect(users).to.have.length(1)
expect(users[0].binary).to.be.an.instanceof.string
expect(users[0].username).to.equal('boo2')
done(); done();
}); });
}); });
...@@ -234,6 +237,60 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -234,6 +237,60 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('should be able to handle binary values through associations as well...', function(done) {
var User = this.User;
var Binary = this.sequelize.define('Binary', {
id: {
type: DataTypes.STRING(16, true),
primaryKey: true
}
})
var buf1 = this.buf
var buf2 = new Buffer(16)
buf2.fill('\x02')
User.belongsTo(Binary, { foreignKey: 'binary' })
User.sync({ force: true }).success(function() {
Binary.sync({ force: true }).success(function() {
User.bulkCreate([
{username: 'boo5', aBool: false},
{username: 'boo6', aBool: true}
]).success(function() {
Binary.bulkCreate([
{id: buf1},
{id: buf2}
]).success(function() {
User.find(1).success(function(user) {
Binary.find(buf1).success(function(binary) {
user.setBinary(binary).success(function() {
User.find(2).success(function(_user) {
Binary.find(buf2).success(function(_binary) {
_user.setBinary(_binary).success(function() {
_user.getBinary().success(function(_binaryRetrieved) {
user.getBinary().success(function(binaryRetrieved) {
expect(binaryRetrieved.id).to.be.an.instanceof.string
expect(_binaryRetrieved.id).to.be.an.instanceof.string
expect(binaryRetrieved.id).to.have.length(16)
expect(_binaryRetrieved.id).to.have.length(16)
expect(binaryRetrieved.id).to.be.equal(buf1.toString())
expect(_binaryRetrieved.id).to.be.equal(buf2.toString())
done()
})
})
})
})
})
})
})
})
})
})
})
})
})
it('should be able to return a record with primaryKey being null for new inserts', function(done) { it('should be able to return a record with primaryKey being null for new inserts', function(done) {
var Session = this.sequelize.define('Session', { var Session = this.sequelize.define('Session', {
token: { type: DataTypes.TEXT, allowNull: false }, token: { type: DataTypes.TEXT, allowNull: false },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!