Skip to content

Commit

Permalink
Merge pull request #60 from ydaniv/bug/58-unique-true
Browse files Browse the repository at this point in the history
Fixed tests for testing issue #58
  • Loading branch information
mccormicka committed May 4, 2014
2 parents c8ecfbb + 06a0ac6 commit 2a4b984
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions test/index.spec.js
Expand Up @@ -48,16 +48,30 @@ describe('Index Tests', function () {

describe('Bugs', function () {

// create a model to work on
mongoose.model('indexUniqueModel', new mongoose.Schema({
name: { type: String, index: { unique: true } }
}));
var IndexUniqueModel = mongoose.model('indexUniqueModel'),
NAME = 'Vlad Impaler';

ddescribe('#58 https://github.com/mccormicka/Mockgoose/issues/58', function () {
it('Support duplicate validation on `index: { unique: true} }`', function (done) {
expect(function () {
new mongoose.Schema({
index: {unique: true}
});
IndexUniqueModel.create({ name: NAME });
}).not.toThrow();
done();
expect(function () {
IndexUniqueModel.create({ name: NAME });
}).toThrow();
IndexUniqueModel.create({ name: NAME }, function (err) {
expect(err).not.toBe(null);
if ( err ) {
expect(err.code).toBe(11000);
}
done();
});
});

});
});
});
});

0 comments on commit 2a4b984

Please sign in to comment.