mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 15:36:33 +00:00
4d81180fc1
Expectations follow createAssignment's options, the stage_ends column, the editor's trip access and the broadcasts of the take-over. Refusals in the run and ski e2e tests go one by one so supertest does not reset a connection under another request. A parity test keeps the source hint enums in step with the contract.
17 lines
751 B
TypeScript
17 lines
751 B
TypeScript
/**
|
|
* Sends requests one after another and answers their results in order.
|
|
*
|
|
* Supertest given an app's HTTP server that is not listening opens it on a
|
|
* port of its own for every request and closes it again once that request is
|
|
* answered. Several requests sent together against the same server race: a
|
|
* refusal answered at once closes it under another one still in flight, which
|
|
* then fails with ECONNRESET instead of its status. Sent one by one, each
|
|
* request has the server to itself.
|
|
*/
|
|
export async function oneByOne<T, R>(items: readonly T[], send: (item: T) => PromiseLike<R>): Promise<R[]> {
|
|
return await items.reduce<Promise<R[]>>(
|
|
async (sent, item) => [...(await sent), await send(item)],
|
|
Promise.resolve([]),
|
|
);
|
|
}
|