Skip to content

Commit ae75c66

Browse files
committed
More stringent testing of remove()
1 parent b50dbcd commit ae75c66

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

test/Model.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe("Model",() => {
218218
describe("remove()",() => {
219219
var model = new Iridium.Model<TestDocument, Test>(core, Test, 'test', { _id: false, answer: Number });
220220

221-
before(() => {
221+
beforeEach(() => {
222222
return core.connect().then(() => model.remove()).then(() => model.insert([
223223
{ answer: 10 },
224224
{ answer: 11 },
@@ -247,13 +247,29 @@ describe("Model",() => {
247247
});
248248

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

253253
it("should support a callback style instead of promises",(done) => {
254254
model.remove((err, removed) => {
255255
if (err) return done(err);
256-
chai.expect(removed).to.exist.and.equal(0);
256+
chai.expect(removed).to.exist.and.equal(5);
257+
return done();
258+
});
259+
});
260+
261+
it("should support a callback style instead of promises when conditions are specified",(done) => {
262+
model.remove({ answer: 10 }, (err, removed) => {
263+
if (err) return done(err);
264+
chai.expect(removed).to.exist.and.equal(1);
265+
return done();
266+
});
267+
});
268+
269+
it("should support a callback style instead of promises when options are specified",(done) => {
270+
model.remove({ answer: 10 }, { w: 1 }, (err, removed) => {
271+
if (err) return done(err);
272+
chai.expect(removed).to.exist.and.equal(1);
257273
return done();
258274
});
259275
});

0 commit comments

Comments
 (0)