Skip to content

Commit

Permalink
add test case for role.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lidianhao123 committed Nov 10, 2017
1 parent d830061 commit 7c14ced
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/rbac.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const mm = require('egg-mock');
const assert = require('power-assert');
const permissions = require('./fixtures/apps/rbac-test/config/rbac').permissions;
const Role = require('../lib/role');

describe('test/rbac.test.js', () => {
let app;
Expand Down Expand Up @@ -89,6 +90,15 @@ describe('test/rbac.test.js', () => {
assert(result[1].ok === 1);
});

it('should return role when new Role width roleName and permissions', function* () {
const roleName = roles[0].name;
const permissions = yield app.rbac.getRolePermission(roleName);
const role = new Role(roleName, permissions);

assert(role.roleName === roleName);
assert(role.canAll(roles[0].grants));
});

it('should GET /admin 200 when role is admin', function* () {
const roleName = 'admin';
const permissions = yield app.rbac.getRolePermission(roleName);
Expand Down

0 comments on commit 7c14ced

Please sign in to comment.