-
Notifications
You must be signed in to change notification settings - Fork 18
/
Intersect.ts
50 lines (38 loc) · 1.53 KB
/
Intersect.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
import { EqualityComparer } from "linq-to-typescript"
import { asAsync, itAsync, itEnumerable, itParallel } from "../TestHelpers"
describe("intersect", () => {
itEnumerable("Basic", (asEnumerable) => {
const array = asEnumerable([1, 2, 3])
.intersect(asEnumerable([1, 2]))
.toArray()
expect(array).toEqual([1, 2])
})
itAsync("Basic", async () => {
const array = await asAsync([1, 2, 3])
.intersect(asAsync([1, 2]))
.toArray()
expect(array).toEqual([1, 2])
})
itParallel("Basic", async (asParallel) => {
const array = await asParallel([1, 2, 3])
.intersect(asAsync([1, 2]))
.toArray()
expect(array).toEqual([1, 2])
})
itEnumerable<string | number>("IntersectWithEqualityComparer", (asEnumerable) => {
const array = asEnumerable([1, 2, "3"]).intersect(asEnumerable(["1", "2"]), EqualityComparer).toArray()
expect(array).toEqual([1, 2])
})
itAsync("IntersectWithEqualityComparer", async () => {
const array = await asAsync([1, 2, "3"])
.intersect(asAsync<string | number>(["1", "2"]), EqualityComparer)
.toArray()
expect(array).toEqual([1, 2])
})
itParallel<string | number>("IntersectWithEqualityComparer", async (asParallel) => {
const array = await asParallel([1, 2, "3"])
.intersect(asAsync<string | number>(["1", "2"]), EqualityComparer)
.toArray()
expect(array).toEqual([1, 2])
})
})