-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathSum.ts
30 lines (24 loc) · 1.02 KB
/
Sum.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
import { asAsync, itAsync, itEnumerable, itParallel } from "../TestHelpers"
describe("sum", () => {
itEnumerable("sum basic", (asEnumerable) => {
expect(asEnumerable([ 43.68, 1.25, 583.7, 6.5 ]).sum()).toBe(635.13)
})
itAsync("sum basic", async () => {
expect(await asAsync([ 43.68, 1.25, 583.7, 6.5 ]).sum()).toBe(635.13)
})
itParallel("sum basic", async (asParallel) => {
expect(await asParallel([ 43.68, 1.25, 583.7, 6.5 ]).sum()).toBe(635.13)
})
itEnumerable<{ a: number }>("sum Selector", (asEnumerable) => {
const zooms = asEnumerable([ { a: 1}, { a: 2 }, {a: 3} ])
expect(zooms.sum((x) => x.a)).toBe(6)
})
itAsync("sum Selector", async () => {
const zooms = asAsync([ { a: 1}, { a: 2 }, {a: 3} ])
expect(await zooms.sum((x) => x.a)).toBe(6)
})
itParallel<{ a: number }>("sum Selector", async (asParallel) => {
const zooms = asParallel([ { a: 1}, { a: 2 }, {a: 3} ])
expect(await zooms.sum((x) => x.a)).toBe(6)
})
})