Skip to content

Commit

Permalink
Added tests for get() and findOne() with empty result sets
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed May 27, 2015
1 parent 98edccd commit 8a950ed
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ describe("Model",() => {
return chai.expect(model.findOne()).to.eventually.exist.and.have.property('answer').is.a('number');
});

it("should support a query which returns nothing",() => {
return chai.expect(model.findOne({ nothing: true })).to.eventually.not.exist;
});

it("should support retrieving a document using its ID",() => {
return chai.expect(model.findOne().then((doc) => model.findOne(doc._id))).to.eventually.exist.and.have.property('answer').is.a('number');
});
Expand Down Expand Up @@ -360,6 +364,10 @@ describe("Model",() => {
return chai.expect(model.get()).to.eventually.exist.and.have.property('answer').is.a('number');
});

it("should support a query which returns nothing",() => {
return chai.expect(model.get({ nothing: true })).to.eventually.not.exist;
});

it("should support retrieving a document using its ID",() => {
return chai.expect(model.get().then((doc) => model.get(doc._id))).to.eventually.exist.and.have.property('answer').is.a('number');
});
Expand Down

0 comments on commit 8a950ed

Please sign in to comment.