fix assert, make the test case more clear
This commit is contained in:
parent
fed0396d9e
commit
45bf569ec4
|
@ -14,24 +14,27 @@ var ModelBuilder = jdb.ModelBuilder;
|
|||
describe('exclude properties ', function() {
|
||||
it('from base model', function(done) {
|
||||
var ds = new ModelBuilder();
|
||||
// this excludes id property from 'base: Model' We still need to pass in idInjection: false since User model tries to
|
||||
// add id again to the model.
|
||||
var User = ds.define('User', {name: String, password: String},
|
||||
{idInjection: false, excludeBaseProperties: ['id']});
|
||||
// User will have these properties: name, password
|
||||
// create a base model User which has name and password properties. id property gets
|
||||
// internally created for the User Model
|
||||
var User = ds.define('User', {name: String, password: String});
|
||||
var properties = User.definition.properties;
|
||||
assert(('name', 'password' in properties));
|
||||
// id should not be found in the properties list
|
||||
assert(!('id' in properties));
|
||||
// this excludes id property from the base model and and password property coming from base 'User' model since customer is
|
||||
// extended from User.
|
||||
// User should have id, name & password properties
|
||||
assert(('id' in properties) && ('password' in properties) && ('name' in properties),
|
||||
'User should have id, name & password properties');
|
||||
// Create sub model Customer with vip as property. id property gets automatically created here as well.
|
||||
// Customer will inherit name, password and id from base User model.
|
||||
// With excludeBaseProperties, 'password' and 'id' gets excluded from base User model
|
||||
// With idInjection: false - id property of sub Model Customer gets excluded. At the end
|
||||
// User will have these 2 properties: name (inherited from User model) and vip (from customer Model).
|
||||
var Customer = User.extend('Customer', {vip: {type: String}},
|
||||
{idInjection: false, excludeBaseProperties: ['password']});
|
||||
// Customer will have these properties: name(from UserModel) & vip
|
||||
{idInjection: false, excludeBaseProperties: ['password', 'id']});
|
||||
// Customer should have these properties: name(from UserModel) & vip
|
||||
properties = Customer.definition.properties;
|
||||
assert(('name', 'vip' in properties));
|
||||
// id and password properties should not be found in the properties list
|
||||
assert(!('id', 'password' in properties));
|
||||
assert(('name' in properties) && ('vip' in properties),
|
||||
'Customer should have name and vip properties');
|
||||
// id or password properties should not be found in the properties list
|
||||
assert(!(('id' in properties) || ('password' in properties)),
|
||||
'Customer should not have id or password properties');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue