Merge pull request #95 from angfal/fix/remote_exists
Add tests to check Model.exists() working
This commit is contained in:
commit
4efca1f052
|
@ -200,6 +200,29 @@ describe('Remote model tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Model.exists(id, callback)', function() {
|
||||
it('should return true when the model with the given id exists',
|
||||
function(done) {
|
||||
ServerModel.create({first: 'max'}, function(err, user) {
|
||||
if (err) return done(err);
|
||||
ClientModel.exists(user.id, function(err, exist) {
|
||||
if (err) return done(err);
|
||||
assert.equal(exist, true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false when there is no model with the given id',
|
||||
function(done) {
|
||||
ClientModel.exists('user-id-does-not-exist', function(err, exist) {
|
||||
if (err) return done(err);
|
||||
assert.equal(exist, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Model.findById(id, callback)', function() {
|
||||
it('should return null when an instance does not exist',
|
||||
function(done) {
|
||||
|
|
Loading…
Reference in New Issue