chore: Fix loading state in the inbox settings page (#4926)

This commit is contained in:
Pranav Raj S 2022-06-24 23:15:46 +05:30 committed by GitHub
parent 263b8240d3
commit c0249a1b5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 97 deletions

View file

@ -1,4 +1,8 @@
import { getLoadingStatus, setLoadingStatus } from '../api';
import {
getLoadingStatus,
parseAPIErrorResponse,
setLoadingStatus,
} from '../api';
describe('#getLoadingStatus', () => {
it('returns correct status', () => {
@ -13,3 +17,23 @@ describe('#setLoadingStatus', () => {
expect(state.fetchAPIloadingStatus).toBe(false);
});
});
describe('#parseAPIErrorResponse', () => {
it('returns correct values', () => {
expect(
parseAPIErrorResponse({
response: { data: { message: 'Error Message [message]' } },
})
).toBe('Error Message [message]');
expect(
parseAPIErrorResponse({
response: { data: { error: 'Error Message [error]' } },
})
).toBe('Error Message [error]');
expect(parseAPIErrorResponse('Error: 422 Failed')).toBe(
'Error: 422 Failed'
);
});
});