Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Oct 10, 2012
1 parent b3a6d45 commit 23e8904
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion entitlement.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function Role(id,rights)

var RootAccount = {
"toString" : function() { return this.id + ': ' + Object.keys(this.roles).join(','); },
"hasEntitlement" : function(entlement) { return false; }
"hasEntitlement" : function(entitlement) { return true; }
};

function Account(id,options)
Expand Down Expand Up @@ -93,6 +93,7 @@ exports.registerAccounts = function(accounts)
exports.accountHasEntitlement = function(account,entitlement)
{
var a = _accounts[account];
//console.log("a: " + account + " -> " + a);
return a && a.hasEntitlement(entitlement) ? true : false;
}

Expand Down
13 changes: 11 additions & 2 deletions tests/entitlement.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var vows = require('vows'),
Entitlement = require('../entitlement').Entitlement,
Role = require('../entitlement').Role,
Account = require('../entitlement').Account,
accountHasEntitlement = require('../entitlement').accountHasEntitlement;
accountHasEntitlement = require('../entitlement').accountHasEntitlement,
registerAccounts = require('../entitlement').registerAccounts;

vows.describe('entitlement').addBatch({
'declare single with description': {
Expand Down Expand Up @@ -47,7 +48,15 @@ vows.describe('entitlement').addBatch({
'entitlement not present': function(flag) {
assert.isFalse(flag);
}
},
'entitlement of known account': {
topic: function() {
registerAccounts({'acc1' :{roles:['role1','role2']}})
return accountHasEntitlement("acc1","role1")
},
'entitlement is present': function(flag) {
assert.isTrue(flag);
}
}

}).export(module);

0 comments on commit 23e8904

Please sign in to comment.