UNPKG

@sazze/acl

Version:
58 lines (38 loc) 1.35 kB
"use strict"; const acl = require('..')(__dirname + '/config/acl'); describe('acl', function() { describe('(is|eq)[LevelName]()', function() { it('should reject invalid roles', function() { (function() { acl.isSuperAdmin(26); }).should.throw(); (function() { acl.eqSuperAdmin(26); }).should.throw(); }); it('should accept valid roles', function() { acl.isAdmin(15).should.be.ok; acl.isAdmin(10).should.not.be.ok; acl.eqAdmin(15).should.be.ok; acl.eqAdmin(20).should.not.be.ok; }); }); describe('isAtLeast()', function() { it('should check if the level you have is at least the level you want', function() { acl.isAtLeast(acl.LEVELS.admin, acl.LEVELS.admin).should.be.ok; acl.isAtLeast(acl.LEVELS.cs, acl.LEVELS.admin).should.not.be.ok; }); }); describe('getLevelsAvailable()', function() { it ('should get only levels <= the given level', function() { let levs = acl.getLevelsAvailable(acl.LEVELS.unverified); levs.should.be.eql([{name: 'Disabled', value: -1}, {name: 'Unverified', value: 0}]) }); }); describe('getLevelDetailsById()', function() { it('should get details', function() { let details = acl.getLevelDetailsById(15); details.name.should.eql('Admin'); }); }) });