Skip to content

Commit

Permalink
add test for static Model.remove() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
alrik committed Jul 21, 2016
1 parent 181b371 commit da9996d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const

describe('MongoTenant', function() {
describe('#Integration', function() {
utils.clearDatabase();

it('should inject default accessor method.', function() {
let Model = utils.createTestModel({});

Expand Down Expand Up @@ -57,5 +59,25 @@ describe('MongoTenant', function() {
'Expected multiple calls to tenant specific model accessor to deliver same model compilation.'
);
});

it('should bind Model.remove() to correct tenant context.', function(done) {
let TestModel = utils.createTestModel({});

TestModel.create({tenantId: 'tenant1'}, {tenantId: 'tenant2'}, (err) => {
assert(!err, 'Expected creation of 2 test entities to work.');

TestModel.byTenant('tenant1').remove((err) => {
assert(!err, 'Expected Model.remove() to work.');

TestModel.find({}, (err, entities) => {
assert(!err, 'Expected Model.find() to work.');
assert.equal(entities.length, 1, 'Expected to find only one entity.');
assert.equal(entities[0].tenantId, 'tenant2', 'Expected tenant2 scope on entity.');

done();
})
});
});
});
});
});

0 comments on commit da9996d

Please sign in to comment.