describe('pipePromise', () => {
const add = (a: number) => Promise.resolve(a + 1);
const multiply = (a: number) => Promise.resolve(a * 2);
const toString = (a: number) => Promise.resolve(String(a));
test('basic pipe', async () => {
const pipe = pipePromise(add, toString);
expect(await pipe(1)).toBe('2');
});
test('multiple functions', async () => {
const pipe = pipePromise(add, multiply, toString);
expect(await pipe(1)).toBe('4');
});
test('error handling', async () => {
const throwError = () => Promise.reject(new Error('test'));
const pipe = pipePromise(add, throwError, toString);
await expect(pipe(1)).rejects.toThrow('test');
});
});