Skip to content

Commit

Permalink
Migrated Bug tests to promises
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Sep 18, 2014
1 parent 73072e3 commit 296bfe5
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions test/bugs.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
var config = require('./config.js');
var Database = require('../index.js');
var Model = Database.Model;
var Instance = Database.Instance;
var should = require('should');
var Concoction = require('concoction');

describe('bugs', function () {
"use strict";
var db = null;
var db = new Database(config);

before(function () {
return db.connect();
});

before(function (done) {
db = new Database(config);
db.connect(done);
after(function() {
db.disconnect();
});

it("shouldn't attempt to change an ObjectID when saving an instance", function(done) {
it("shouldn't attempt to change an ObjectID when saving an instance", function() {
var model = new Model(db, 'model', {
id: false,
data: [String]
}, {

});

model.remove(function(err) {
if(err) return done(err);

model.create({ data: ['testing'] }, function(err, instance) {
if(err) return done(err);
should.exist(instance);

instance.data.push('tested');
instance.save(function(err) {
should.not.exist(err);
instance.data.should.eql(['testing', 'tested']);
done();
});
});
model.remove().then(function() {
return model.create({ data: ['testing'] });
}).then(function(instance) {
instance.data.push('tested');
return instance.save();
}).then(function(instance) {
instance.data.should.be.like(['testing', 'tested']);
});
});
});

0 comments on commit 296bfe5

Please sign in to comment.