|
|
@@ -34,4 +34,22 @@ describe('test CheckPermissions', () => {
|
|
|
it('Correct Function permission authentication', () => {
|
|
|
expect(checkPermissions(() => true, 'guest', target, error)).toEqual('ok');
|
|
|
});
|
|
|
+ it('authority is string, currentAuthority is array, return ok', () => {
|
|
|
+ expect(checkPermissions('user', ['user'], target, error)).toEqual('ok');
|
|
|
+ });
|
|
|
+ it('authority is string, currentAuthority is array, return ok', () => {
|
|
|
+ expect(checkPermissions('user', ['user', 'admin'], target, error)).toEqual('ok');
|
|
|
+ });
|
|
|
+ it('authority is array, currentAuthority is array, return ok', () => {
|
|
|
+ expect(checkPermissions(['user', 'admin'], ['user', 'admin'], target, error)).toEqual('ok');
|
|
|
+ });
|
|
|
+ it('Wrong Function permission authentication', () => {
|
|
|
+ expect(checkPermissions(() => false, ['user'], target, error)).toEqual('error');
|
|
|
+ });
|
|
|
+ it('Correct Function permission authentication', () => {
|
|
|
+ expect(checkPermissions(() => true, ['user'], target, error)).toEqual('ok');
|
|
|
+ });
|
|
|
+ it('authority is undefined , return ok', () => {
|
|
|
+ expect(checkPermissions(null, ['user'], target, error)).toEqual('ok');
|
|
|
+ });
|
|
|
});
|