chore: Add ee helper, custom_attributes to account (#5058)

This commit is contained in:
Pranav Raj S
2022-07-19 00:33:06 +05:30
committed by GitHub
parent d8140db2e8
commit 1dc7ce526e
14 changed files with 56 additions and 23 deletions
@@ -55,3 +55,8 @@ export const parseAPIErrorResponse = error => {
}
return error;
};
export const throwErrorMessage = error => {
const errorMessage = parseAPIErrorResponse(error);
throw new Error(errorMessage);
};
@@ -2,6 +2,7 @@ import {
getLoadingStatus,
parseAPIErrorResponse,
setLoadingStatus,
throwErrorMessage,
} from '../api';
describe('#getLoadingStatus', () => {
@@ -37,3 +38,14 @@ describe('#parseAPIErrorResponse', () => {
);
});
});
describe('#throwErrorMessage', () => {
it('throws correct error', () => {
const errorFn = function throwErrorMessageFn() {
throwErrorMessage({
response: { data: { message: 'Error Message [message]' } },
});
};
expect(errorFn).toThrow('Error Message [message]');
});
});