Skip to content

Commit

Permalink
Merge 25c90e8 into 0455836
Browse files Browse the repository at this point in the history
  • Loading branch information
salilagrawal committed Oct 9, 2018
2 parents 0455836 + 25c90e8 commit c1902dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/fetchUtils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { withHeaders } from './withHeaders';

export const defaultHeaders = {
'Accept': 'application/json',
'Content-Type': 'application/json'
};
export const defaultHeaders = {};

export const handlers = {};

Expand Down Expand Up @@ -31,7 +28,7 @@ handlers.decode = function (response) {
if (contentType.includes('application/json')) {
return response.json()
.then(data => handlers.finish(response, data));
} else if (contentType.includes('text/html')) {
} else if (contentType.includes('text/html') || contentType.includes('text/plain')) {
return response.text()
.then(data => handlers.finish(response, data));
}
Expand Down
8 changes: 8 additions & 0 deletions tests/fetchUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ describe('fetchUtils', () => {
});
});

it('decodes and resolves PLAIN TEXT content', (done) => {
mockResponse.headers.set('content-type', 'text/plain');
handlers.decode(mockResponse).then(data => {
expect(data).toBe(mockTextData);
done();
});
});

it('rejects for unhandled content types', (done) => {
mockResponse.headers.set('content-type', 'some/type');
handlers.decode(mockResponse).catch(data => {
Expand Down

0 comments on commit c1902dd

Please sign in to comment.