test(async): use generic assertRejects in pool_test.ts (#2287)

Fixes a deprecation warning. Resolves https://github.com/denoland/deno_std/issues/2283
This commit is contained in:
Matthew Leon 2022-05-30 12:21:28 +02:00 committed by GitHub
parent 564d2ed8ab
commit 3c129122f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,17 +34,16 @@ Deno.test("[async] pooledMap errors", async () => {
return n;
}
const mappedNumbers: number[] = [];
await assertRejects(async () => {
const error = await assertRejects(async () => {
for await (const m of pooledMap(3, [1, 2, 3, 4], mapNumber)) {
mappedNumbers.push(m);
}
}, (error: Error) => {
assert(error instanceof AggregateError);
assert(error.message === ERROR_WHILE_MAPPING_MESSAGE);
assertEquals(error.errors.length, 2);
assertStringIncludes(error.errors[0].stack, "Error: Bad number: 1");
assertStringIncludes(error.errors[1].stack, "Error: Bad number: 2");
});
}, AggregateError);
assert(error instanceof AggregateError);
assert(error.message === ERROR_WHILE_MAPPING_MESSAGE);
assertEquals(error.errors.length, 2);
assertStringIncludes(error.errors[0].stack, "Error: Bad number: 1");
assertStringIncludes(error.errors[1].stack, "Error: Bad number: 2");
assertEquals(mappedNumbers, [3]);
});