Skip to content

Commit

Permalink
Clean up saved object authorization unit tests / errors
Browse files Browse the repository at this point in the history
One error message was incorrect. Converted to get rid of snapshots.
  • Loading branch information
jportner committed Sep 23, 2020
1 parent e8f0b1d commit e93f563
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ describe('#get', () => {
[null, undefined, '', 1, true, {}].forEach((type: any) => {
test(`type of ${JSON.stringify(type)} throws error`, () => {
const savedObjectActions = new SavedObjectActions(version);
expect(() => savedObjectActions.get(type, 'foo-action')).toThrowErrorMatchingSnapshot();
expect(() => savedObjectActions.get(type, 'foo-action')).toThrowError(
'type is required and must be a string'
);
});
});

[null, undefined, '', 1, true, {}].forEach((operation: any) => {
test(`operation of ${JSON.stringify(operation)} throws error`, () => {
const savedObjectActions = new SavedObjectActions(version);
expect(() => savedObjectActions.get('foo-type', operation)).toThrowErrorMatchingSnapshot();
expect(() => savedObjectActions.get('foo-type', operation)).toThrowError(
'operation is required and must be a string'
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class SavedObjectActions {
}

if (!operation || !isString(operation)) {
throw new Error('type is required and must be a string');
throw new Error('operation is required and must be a string');
}

return `${this.prefix}${type}/${operation}`;
Expand Down

0 comments on commit e93f563

Please sign in to comment.