1 | import {expectError, expectType} from 'tsd';
|
2 | import any from '.';
|
3 |
|
4 | expectType<{ [key: string]: string }>(any.simpleObject());
|
5 |
|
6 | expectType<{ a: number, b: number, c: number }>(any.objectWithKeys(['a', 'b', 'c'], {factory: any.integer()}));
|
7 | expectError(any.objectWithKeys())
|
8 |
|
9 | expectType<string | number>(any.fromList(['a', 1]))
|
10 | expectError(any.fromList())
|
11 |
|
12 | expectType<string[]>(any.subList(['a', 'b', 'c']))
|
13 | expectType<string[]>(any.subList(['a', 'b', 'c'], {size: 2}))
|
14 | expectError(any.subList())
|
15 |
|
16 | expectType<string>(any.string());
|
17 | expectType<string>(any.string({length: 1}));
|
18 | expectType<string>(any.string({length: 1, alpha: true, pool: 'abcde', casing: 'lower', numeric: true, symbols: true}));
|
19 |
|
20 | expectType<string>(any.word())
|
21 | expectType<string>(any.word({length: 1}))
|
22 | expectType<string>(any.word({length: 1, capitalize: true}))
|
23 | expectType<string>(any.word({length: 1, capitalize: true, syllables: 1}))
|
24 |
|
25 | expectType<string>(any.sentence())
|
26 | expectType<string>(any.sentence({words: 1}))
|
27 | expectType<string>(any.sentence({words: 1, punctuation: '.'}))
|
28 |
|
29 | expectType<string>(any.paragraph())
|
30 | expectType<string>(any.paragraph({sentences: 1}))
|
31 |
|
32 | expectType<number>(any.integer())
|
33 | expectType<number>(any.integer({min: 1}))
|
34 | expectType<number>(any.integer({min: 1, max: 2}))
|
35 |
|
36 | expectType<number>(any.float())
|
37 | expectType<number>(any.float({min: 1}))
|
38 | expectType<number>(any.float({min: 1, max: 2}))
|
39 | expectType<number>(any.float({min: 1, max: 2, fixed: 4}))
|
40 |
|
41 | expectType<boolean>(any.boolean())
|
42 | expectType<boolean>(any.boolean({likelihood: 30}))
|
43 |
|
44 | expectType<string>(any.url());
|
45 | expectType<string>(any.url({protocol: 'https'}));
|
46 | expectType<string>(any.url({
|
47 | protocol: 'https',
|
48 | domain: 'google',
|
49 | domain_prefix: 'a',
|
50 | path: 'search',
|
51 | extensions: ['.jpg']
|
52 | }));
|
53 |
|
54 | expectType<string>(any.email());
|
55 | expectType<string>(any.email({length: 1}));
|
56 | expectType<string>(any.email({length: 1, domain: 'gmail.com'}));
|
57 |
|
58 | expectType<string>(any.date());
|