Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Jan 21, 2022
1 parent d92ba60 commit eeadcc0
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions test/ScopeGuard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ describe('ScopeGuard', async () => {
).to.be.revertedWith('caller is not the owner');
});

it('should allow delegate calls for a target', async () => {
it('should allow delegate calls to a target', async () => {
const { guard } = await setupTests();
expect(await guard.canDelegateCallToTarget(guard.address)).to.be.equals(
false
Expand All @@ -470,7 +470,7 @@ describe('ScopeGuard', async () => {
);
});

it('should disallow delegate calls for a target', async () => {
it('should disallow delegate calls to a target', async () => {
const { guard } = await setupTests();
expect(await guard.canDelegateCallToTarget(guard.address)).to.be.equals(
false
Expand Down Expand Up @@ -503,6 +503,45 @@ describe('ScopeGuard', async () => {
);
});

it('should allow sending to a target', async () => {
const { guard } = await setupTests();
expect(await guard.canSendToTarget(guard.address)).to.be.equals(false);
await expect(
guard.setExecutionOptions(guard.address, ExecutionOptions.SEND)
)
.to.emit(guard, 'SetExecutionOptions')
.withArgs(guard.address, ExecutionOptions.SEND);
expect(await guard.canSendToTarget(guard.address)).to.be.equals(true);
});

it('should disallow sending to a target', async () => {
const { guard } = await setupTests();
expect(await guard.canSendToTarget(guard.address)).to.be.equals(false);
await expect(
guard.setExecutionOptions(guard.address, ExecutionOptions.SEND)
);
expect(await guard.canSendToTarget(guard.address)).to.be.equals(true);

await expect(
guard.setExecutionOptions(guard.address, ExecutionOptions.NONE)
);
expect(await guard.canSendToTarget(guard.address)).to.be.equals(false);
});

it('should return true if allowed to send to a target', async () => {
const { avatar, guard } = await setupTests();

expect(await guard.canSendToTarget(avatar.address)).to.be.equals(false);
await expect(
guard.setExecutionOptions(avatar.address, ExecutionOptions.SEND)
);
expect(await guard.canSendToTarget(avatar.address)).to.be.equals(true);
await expect(
guard.setExecutionOptions(avatar.address, ExecutionOptions.BOTH)
);
expect(await guard.canSendToTarget(avatar.address)).to.be.equals(true);
});

it('should emit SetExecutionOptions(target, options)', async () => {
const { avatar, guard } = await setupTests();
await expect(
Expand Down

0 comments on commit eeadcc0

Please sign in to comment.