Skip to content

Commit

Permalink
Rename handleAPIError to flashAPIErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Sep 14, 2020
1 parent 5287c75 commit ad4f8fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jest.mock('./', () => ({
}));
import { FlashMessagesLogic } from './';

import { handleAPIError } from './handle_api_errors';
import { flashAPIErrors } from './handle_api_errors';

describe('handleAPIError', () => {
describe('flashAPIErrors', () => {
const mockHttpError = {
body: {
statusCode: 404,
Expand All @@ -33,7 +33,7 @@ describe('handleAPIError', () => {
});

it('converts API errors into flash messages', () => {
handleAPIError(mockHttpError);
flashAPIErrors(mockHttpError);

expect(FlashMessagesLogic.actions.setFlashMessages).toHaveBeenCalledWith([
{ type: 'error', message: 'Could not find X' },
Expand All @@ -43,7 +43,7 @@ describe('handleAPIError', () => {
});

it('queues messages when isQueued is passed', () => {
handleAPIError(mockHttpError, { isQueued: true });
flashAPIErrors(mockHttpError, { isQueued: true });

expect(FlashMessagesLogic.actions.setQueuedMessages).toHaveBeenCalledWith([
{ type: 'error', message: 'Could not find X' },
Expand All @@ -54,7 +54,7 @@ describe('handleAPIError', () => {

it('displays a generic error message and re-throws non-API errors', () => {
try {
handleAPIError(Error('whatever') as any);
flashAPIErrors(Error('whatever') as any);
} catch (e) {
expect(e.message).toEqual('whatever');
expect(FlashMessagesLogic.actions.setFlashMessages).toHaveBeenCalledWith([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface IOptions {
/**
* Converts API/HTTP errors into user-facing Flash Messages
*/
export const handleAPIError = (
export const flashAPIErrors = (
error: HttpResponse<IErrorResponse>,
{ isQueued }: IOptions = {}
) => {
Expand Down

0 comments on commit ad4f8fd

Please sign in to comment.