-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
chain_test.ts
34 lines (31 loc) · 1 KB
/
chain_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { test } from "@cross/test";
import { assertEquals } from "@std/assert";
import { assertType, type IsExact } from "@std/testing/types";
import { chain } from "./chain.ts";
await test("chain with empty iterables", () => {
const result = chain([] as number[], [] as string[]);
const expected = [] as (number | string)[];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number | string>>>(true);
});
await test("chain with iterables", () => {
const result = chain(
[1, 2, 3],
["a", "b"],
);
const expected = [1, 2, 3, "a", "b"];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number | string>>>(true);
});
await test("chain with multiple iterables", () => {
const result = chain(
[1, 2, 3],
["a", "b"],
[true],
);
const expected = [1, 2, 3, "a", "b", true];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number | string | boolean>>>(
true,
);
});