-
Notifications
You must be signed in to change notification settings - Fork 18
/
Repeat.ts
31 lines (25 loc) · 1.08 KB
/
Repeat.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
import { ArgumentOutOfRangeException, repeat, repeatAsync, repeatParallel } from "linq-to-typescript"
import { itAsync, itEnumerable, itParallel } from "../../TestHelpers"
describe("repeat", () => {
itEnumerable("Repeat 10", () => {
const oneToTen = repeat(1, 10).toArray()
expect(oneToTen).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
})
itAsync("Repeat 10", async () => {
const oneToTen = await repeatAsync(1, 10).toArray()
expect(oneToTen).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
})
itParallel("Repeat 10", async () => {
const oneToTen = await repeatParallel(1, 10).toArray()
expect(oneToTen).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
})
itEnumerable("Repeat Throws", () => {
expect(() => repeat(1, -1)).toThrowError(ArgumentOutOfRangeException)
})
itAsync("Repeat Throws", async () => {
expect(() => repeatAsync(1, -1)).toThrowError(ArgumentOutOfRangeException)
})
itParallel("Repeat Throws", () => {
expect(() => repeatParallel(1, -1)).toThrowError(ArgumentOutOfRangeException)
})
})