This repository was archived by the owner on Feb 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop.test.ts
51 lines (49 loc) · 1.62 KB
/
drop.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import type { Tests } from "@vangware/test";
import type { ReadOnlyArray } from "@vangware/types";
import { drop } from "../src/drop.js";
import { iterableToArray } from "../src/iterableToArray.js";
import { asyncIterateArray } from "./utils.js";
const drop2 = drop(2);
const dropNone = drop(0);
const dropAll = drop(Infinity);
export default [
{
given: "an iterable of numbers and a drop 2 function",
must: "return iterable without the first 2 elements",
received: () => iterableToArray(drop2([0, 1, 2, 3, 4])),
wanted: () => [2, 3, 4],
},
{
given: "an iterable of numbers and a drop 0 function",
must: "return iterable with all its elements",
received: () => iterableToArray(dropNone([0, 1, 2, 3, 4])),
wanted: () => [0, 1, 2, 3, 4],
},
{
given: "an iterable of numbers and a drop all function",
must: "return empty iterable",
received: () => iterableToArray(dropAll([0, 1, 2, 3, 4])),
wanted: () => [],
},
{
given: "an async iterable of numbers and a drop 2 function",
must: "return iterable without the first 2 elements",
received: () =>
iterableToArray(drop2(asyncIterateArray([0, 1, 2, 3, 4]))),
wanted: () => [2, 3, 4],
},
{
given: "an async iterable of numbers and a drop 0 function",
must: "return iterable with all its elements",
received: () =>
iterableToArray(dropNone(asyncIterateArray([0, 1, 2, 3, 4]))),
wanted: () => [0, 1, 2, 3, 4],
},
{
given: "an async iterable of numbers and a drop all function",
must: "return empty iterable",
received: () =>
iterableToArray(dropAll(asyncIterateArray([0, 1, 2, 3, 4]))),
wanted: () => [],
},
] satisfies Tests<ReadOnlyArray<number>>;