-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(actionbasedstatement): throw TypeError when action and notAction …
…are present
- Loading branch information
1 parent
f78553e
commit 2e4409d
Showing
5 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ActionBased } from './ActionBasedStatement'; | ||
|
||
describe('ActionBased Class', () => { | ||
describe('when creating action based statement', () => { | ||
it("doesn't throw an error", () => { | ||
expect( | ||
() => | ||
new ActionBased({ | ||
action: ['read', 'write'] | ||
}) | ||
).not.toThrow(); | ||
expect( | ||
() => | ||
new ActionBased({ | ||
notAction: ['write'] | ||
}) | ||
).not.toThrow(); | ||
}); | ||
|
||
it('throws a TypeError', () => { | ||
const expectedError = new TypeError( | ||
'ActionBased statement should have an action or a notAction attribute, no both' | ||
); | ||
expect(() => { | ||
new ActionBased({ | ||
action: ['read', 'write'], | ||
notAction: 'delete' | ||
}); | ||
}).toThrow(expectedError); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters