..
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 | import { describe, expect, it } from 'vitest';
import { faker } from '../dist/cjs';
describe('word', () => {
const methods = [
'adjective',
'adverb',
'conjunction',
'interjection',
'noun',
'preposition',
'verb',
];
// Perform the same three tests for each method.
methods.forEach((method) => {
describe(method + '()', () => {
it('returns random value from ' + method + ' array', () => {
const word = faker.word[method]();
expect(faker.definitions.word[method]).toContain(word);
});
it('optional length parameter returns expected result', () => {
const wordLength = 5;
const word = faker.word[method](wordLength);
expect(faker.definitions.word[method]).toContain(word);
expect(word.length).toBe(wordLength);
});
it('unresolvable optional length returns random ' + method, () => {
const wordLength = 1000;
const word = faker.word[method](wordLength);
expect(faker.definitions.word[method]).toContain(word);
});
});
});
});
|
|