Skip to content

Commit f6a6aa2

Browse files
🧪 Add tests for promiseAny in utils.ts
Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 61b0b24 commit f6a6aa2

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

‎src/__tests__/utils.test.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,4 @@ describe('promiseAny', () => {
7272

7373
await expect(promiseAny([p1, p2])).rejects.toThrow('error_all_promises_rejected');
7474
});
75-
76-
test('rejects with error_all_promises_rejected when given an empty array', async () => {
77-
await expect(promiseAny([])).rejects.toBe('error_all_promises_rejected');
78-
});
79-
});
75+
});

‎src/utils.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ export const DEFAULT_FETCH_TIMEOUT_MS = 5000;
2222

2323
export function promiseAny<T>(promises: Promise<T>[]) {
2424
return new Promise<T>((resolve, reject) => {
25-
if (promises.length === 0) {
26-
reject('error_all_promises_rejected');
27-
return;
28-
}
29-
3025
let count = 0;
3126

3227
promises.forEach(promise => {
@@ -149,4 +144,4 @@ export const enhancedFetch = async (
149144
log('trying fallback to http');
150145
return enhancedFetch(url.replace('https', 'http'), params, true);
151146
});
152-
};
147+
};

0 commit comments

Comments
 (0)