Skip to content

Commit

Permalink
Improve role behavior tests (#1300)
Browse files Browse the repository at this point in the history
* The public role behavior now also tests the modifer.

* Fixed linter error.
  • Loading branch information
nventuro authored Sep 7, 2018
1 parent 9514606 commit 254210f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/access/roles/PublicRole.behavior.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { assertRevert } = require('../../helpers/assertRevert');
const expectEvent = require('../../helpers/expectEvent');

require('chai')
Expand All @@ -18,6 +19,24 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
(await this.contract[`is${rolename}`](anyone)).should.equal(false);
});

describe('access control', function () {
context('from authorized account', function () {
const from = authorized;

it('allows access', async function () {
await this.contract[`only${rolename}Mock`]({ from });
});
});

context('from unauthorized account', function () {
const from = anyone;

it('reverts', async function () {
await assertRevert(this.contract[`only${rolename}Mock`]({ from }));
});
});
});

describe('add', function () {
it('adds role to a new account', async function () {
await this.contract[`add${rolename}`](anyone, { from: authorized });
Expand Down

0 comments on commit 254210f

Please sign in to comment.