Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/modules/lorem/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class LoremModule extends ModuleBase {
* - `longest`: Returns any of the longest words.
* - `any-length`: Returns a word with any length.
*
* Defaults to `'any-length'`.
* Defaults to `'fail'`.
*
* @example
* faker.lorem.word() // 'temporibus'
Expand All @@ -46,7 +46,7 @@ export class LoremModule extends ModuleBase {
/**
* The expected length of the word.
*
* @default 1
* If not provided, a word of any length is returned.
*/
length?: number | NumberRange;
/**
Expand All @@ -60,7 +60,7 @@ export class LoremModule extends ModuleBase {
* - `longest`: Returns any of the longest words.
* - `any-length`: Returns a word with any length.
*
* @default 'any-length'
* @default 'fail'
*/
strategy?: 'fail' | 'closest' | 'shortest' | 'longest' | 'any-length';
} = {}
Expand Down
6 changes: 6 additions & 0 deletions test/modules/lorem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ describe('lorem', () => {
expect(actual).toHaveLength(length);
}
);

it('should throw by default when no word matches the requested length', () => {
expect(() => faker.lorem.word({ length: 100 })).toThrow(
'No words found that match the given length.'
);
});
});

describe('words()', () => {
Expand Down
Loading