Skip to content

Commit

Permalink
More stringent testing of remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed May 26, 2015
1 parent b50dbcd commit ae75c66
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe("Model",() => {
describe("remove()",() => {
var model = new Iridium.Model<TestDocument, Test>(core, Test, 'test', { _id: false, answer: Number });

before(() => {
beforeEach(() => {
return core.connect().then(() => model.remove()).then(() => model.insert([
{ answer: 10 },
{ answer: 11 },
Expand Down Expand Up @@ -247,13 +247,29 @@ describe("Model",() => {
});

it("should allow the removal of all documents",() => {
return chai.expect(model.remove()).to.eventually.equal(3);
return chai.expect(model.remove()).to.eventually.equal(5);
});

it("should support a callback style instead of promises",(done) => {
model.remove((err, removed) => {
if (err) return done(err);
chai.expect(removed).to.exist.and.equal(0);
chai.expect(removed).to.exist.and.equal(5);
return done();
});
});

it("should support a callback style instead of promises when conditions are specified",(done) => {
model.remove({ answer: 10 }, (err, removed) => {
if (err) return done(err);
chai.expect(removed).to.exist.and.equal(1);
return done();
});
});

it("should support a callback style instead of promises when options are specified",(done) => {
model.remove({ answer: 10 }, { w: 1 }, (err, removed) => {
if (err) return done(err);
chai.expect(removed).to.exist.and.equal(1);
return done();
});
});
Expand Down

0 comments on commit ae75c66

Please sign in to comment.