mirror of
https://github.com/SomboChea/ui
synced 2026-01-19 17:46:12 +07:00
fix(api): correctly handle responses with missing content-type header
Also prevents non .tgz requests from being handled as tgz requests — the previous if condition was incorrect
This commit is contained in:
@@ -11,6 +11,22 @@ describe('api', () => {
|
||||
};
|
||||
|
||||
describe('handleResponseType', () => {
|
||||
test('should handle missing Content-Type', async () => {
|
||||
const response: Response = {
|
||||
url: 'http://localhost:8080/-/packages',
|
||||
ok: false,
|
||||
// @ts-ignore
|
||||
headers: {
|
||||
get: () => null,
|
||||
} as Headers,
|
||||
} as Response;
|
||||
|
||||
const handled = await handleResponseType(response);
|
||||
|
||||
// Should this actually return [false, null] ?
|
||||
expect(handled).toBeUndefined();
|
||||
});
|
||||
|
||||
test('should test tgz scenario', async () => {
|
||||
const blob = new Blob(['foo']);
|
||||
const blobPromise = Promise.resolve<Blob>(blob);
|
||||
|
||||
Reference in New Issue
Block a user