Skip to content

Commit

Permalink
Support allowDiskUse, exec and mongoose.Types
Browse files Browse the repository at this point in the history
  • Loading branch information
gflandre committed Jun 10, 2015
1 parent cd643dc commit 8a1b457
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ var Schema = function () {
};

Model.aggregate = sinon.stub();
Model.allowDiskUse = sinon.stub();
Model.count = sinon.stub();
Model.create = sinon.stub();
Model.distinct = sinon.stub();
Model.ensureIndexes = sinon.stub();
Model.exec = sinon.stub();
Model.find = sinon.stub();
Model.findById = sinon.stub();
Model.findByIdAndRemove = sinon.stub();
Expand Down Expand Up @@ -106,6 +108,7 @@ function createModelFromSchema(name, Type) {

mongoose.Schema = Schema;
mongoose.Schema.Types = { ObjectId: ''}; // Defining mongoose types as dummies.
mongoose.Types = mongoose.Schema.Types;
mongoose.model = createModelFromSchema;
mongoose.connect = sinon.stub;

7 changes: 7 additions & 0 deletions test/unit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('mongoose-mocks', function () {
describe('mongoose Types', function() {
it('should have an ObjectId type', function() {
expect(Schema.Types).to.have.a.property('ObjectId');
expect(mongoose.Types).to.have.a.property('ObjectId');
});
});
describe('mongoose Model functions', function () {
Expand All @@ -33,6 +34,9 @@ describe('mongoose-mocks', function () {
it('adds a stub for aggregate()', function () {
expect(Model.aggregate).to.be.a('function');
});
it('adds a stub for allowDiskUse()', function () {
expect(Model.aggregate).to.be.a('function');
});
it('adds a stub for count()', function () {
expect(Model.count).to.be.a('function');
});
Expand All @@ -45,6 +49,9 @@ describe('mongoose-mocks', function () {
it('adds a stub for ensureIndexes()', function () {
expect(Model.ensureIndexes).to.be.a('function');
});
it('adds a stub for exec()', function () {
expect(Model.exec).to.be.a('function');
});
it('adds a stub for find()', function () {
expect(Model.find).to.be.a('function');
});
Expand Down

0 comments on commit 8a1b457

Please sign in to comment.