-
Notifications
You must be signed in to change notification settings - Fork 18
/
toObjectAsync.ts
37 lines (30 loc) · 1.13 KB
/
toObjectAsync.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
import { asAsync, itAsync, itEnumerableAsync, itParallel } from "../TestHelpers"
const objectKeys = <TObject extends object>(object: TObject) => {
return Object.keys(object) as Array<keyof TObject>
}
describe("toObjectAsync", () => {
itEnumerableAsync("basic", async (asEnumerable) => {
const object = await asEnumerable([1, 2, 3])
.toObjectAsync(async (x) => `Key_${ x }`)
for (const key of objectKeys(object)) {
const value = object[key]
expect(key).toBe(`Key_${ value }`)
}
})
itAsync("basic", async () => {
const object = await asAsync([1, 2, 3])
.toObjectAsync(async (x) => `Key_${ x }`)
for (const key of objectKeys(object)) {
const value = object[key]
expect(key).toBe(`Key_${ value }`)
}
})
itParallel("basic", async (asParallel) => {
const object = await asParallel([1, 2, 3])
.toObjectAsync(async (x) => `Key_${ x }`)
for (const key of objectKeys(object)) {
const value = object[key]
expect(key).toBe(`Key_${ value }`)
}
})
})