webstreamr-github/src/utils/promise.test.ts
2025-05-07 21:09:18 +00:00

16 lines
604 B
TypeScript

import { fulfillAllPromises } from './promise';
describe('promise', () => {
test('fulfillAllPromises returns all resolved promise values and logs rejected ones', async () => {
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => undefined);
const results = await fulfillAllPromises([
Promise.resolve('ok'),
Promise.reject('not ok'),
]);
expect(results).toStrictEqual(['ok']);
expect(consoleErrorSpy).toHaveBeenCalled();
expect(consoleErrorSpy).toHaveBeenCalledWith(expect.stringContaining('Could not fulfill promise: not ok'));
});
});