-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharbitraties.ts
46 lines (36 loc) · 904 Bytes
/
arbitraties.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
import * as fc from "fast-check";
import { isValidTodo, repeatWhiteSpace } from "./utils";
export function validToDoArbitrary() {
return fc.unicodeString()
.filter(isValidTodo)
.map(text => ({
text: text,
type: 'valid' as const
}))
}
export function whitespaceToDoArbitrary() {
return fc.integer(1, 15)
.map(repeatWhiteSpace)
.map(text => ({
text: text,
type: 'whitespace' as const
}))
}
export function trimToDoArbitrary() {
return fc.record({
start: fc.integer(1, 15),
middle: validToDoArbitrary(),
end: fc.integer(1, 15),
})
.map(x => `${repeatWhiteSpace(x.start)}${x.middle.text}${repeatWhiteSpace(x.end)}`)
.map(text => ({
text: text,
type: 'trim' as const
}))
}
export function emptyToDoArbitrary() {
return fc.record({
text: fc.constant(''),
type: fc.constant('empty' as const)
})
}