Skip to content

Commit

Permalink
More promises
Browse files Browse the repository at this point in the history
  • Loading branch information
seth-admittedly committed Nov 6, 2014
1 parent 1007ac2 commit 6825450
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions test/postgres/dao.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,38 +457,30 @@ if (dialect.match(/^postgres/)) {
})
})

it("should read hstore correctly", function(done) {
it("should read hstore correctly", function() {
var self = this
var data = { username: 'user', email: ['foo@bar.com'], settings: { test: '"value"' }}

this.User
.create(data)
.success(function() {
return this.User.create(data)
.then(function() {
return self.User.find({ where: { username: 'user' }})
})
.then(function(user){
// Check that the hstore fields are the same when retrieving the user
self.User.find({ where: { username: 'user' }})
.success(function(user) {
expect(user.settings).to.deep.equal(data.settings)

done()
})
expect(user.settings).to.deep.equal(data.settings)
})
.error(console.log)
})

it('should read an hstore array correctly', function(done) {
it('should read an hstore array correctly', function() {
var self = this
var data = { username: 'user', email: ['foo@bar.com'], phones: [{ number: '123456789', type: 'mobile' }, { number: '987654321', type: 'landline' }] }

this.User
.create(data)
.success(function() {
return this.User.create(data)
.then(function() {
// Check that the hstore fields are the same when retrieving the user
self.User.find({ where: { username: 'user' }})
.success(function(user) {
expect(user.phones).to.deep.equal(data.phones)

done()
})
return self.User.find({ where: { username: 'user' }});
}).then(function(user) {
expect(user.phones).to.deep.equal(data.phones)
})
})

Expand Down

0 comments on commit 6825450

Please sign in to comment.