Skip to content

Commit

Permalink
Add test case for all() types
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Dec 29, 2023
1 parent fa5cf8a commit 2cae70a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import {
asyncResource,
describe,
expect,
expectType,
it,
syncReject,
syncResolve,
} from "./suite.ts";

import { all, run, sleep } from "../mod.ts";
import { all, call, type Operation, run, sleep } from "../mod.ts";

describe("all()", () => {
it("resolves when the given list is empty", async () => {
Expand Down Expand Up @@ -92,4 +93,18 @@ describe("all()", () => {
expect(fooStatus.status).toEqual("pending");
});
});

it("has a type signature equivalent to Promise.all()", () => {
let resolve = <T>(value: T) =>
call(function* () {
return value;
});

expectType<Operation<[string, number, string]>>(
all([resolve("hello"), resolve(42), resolve("world")]),
);
expectType<Operation<[string, number]>>(
all([resolve("hello"), resolve(42)]),
);
});
});

0 comments on commit 2cae70a

Please sign in to comment.