Skip to content

Commit

Permalink
add test helper utils
Browse files Browse the repository at this point in the history
  • Loading branch information
onury committed Nov 23, 2017
1 parent 1ac5301 commit 5981f5a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

/**
* Test Helper
* @author Onur Yıldırım <[email protected]>
*/

import { AccessControl } from '../src';

const helper = {
expectACError(fn: any, errMsg?: string) {
expect(fn).toThrow();
try {
fn();
} catch (err) {
expect(err instanceof AccessControl.Error).toEqual(true);
expect(AccessControl.isAccessControlError(err)).toEqual(true);
expect(AccessControl.isACError(err)).toEqual(true); // alias test
if (errMsg) expect(err.message).toContain(errMsg);
}
}

};

export { helper };

0 comments on commit 5981f5a

Please sign in to comment.