diff options
| author | DivisionByZero <[email protected]> | 2025-07-06 17:43:03 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-06 15:43:03 +0000 |
| commit | 93416f71cf0ddf32dd12c181c862a1b59ef4fd86 (patch) | |
| tree | a5a25415dd2fa4e58ef513322313ef926c4c607a /test/modules/word.spec.ts | |
| parent | 89720601bb8becffd39c516a6264c411f4a557a7 (diff) | |
| download | faker-93416f71cf0ddf32dd12c181c862a1b59ef4fd86.tar.xz faker-93416f71cf0ddf32dd12c181c862a1b59ef4fd86.zip | |
refactor(word)!: change default error strategy to 'fail' (#3560)
Diffstat (limited to 'test/modules/word.spec.ts')
| -rw-r--r-- | test/modules/word.spec.ts | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/test/modules/word.spec.ts b/test/modules/word.spec.ts index 121cce84..646bbc06 100644 --- a/test/modules/word.spec.ts +++ b/test/modules/word.spec.ts @@ -19,9 +19,8 @@ describe('word', () => { 'sample' )((t) => { t.it('noArgs') - .it('with length = 10', 10) - .it('with length = 20', 20) - .it('with options.length', { length: 10 }) + .it('with length = 4', 4) + .it('with options.length', { length: 4 }) .it('with options.strategy', { strategy: 'shortest' }) .it('with options.length and options.strategy', { length: { min: 18, max: 20 }, @@ -31,9 +30,8 @@ describe('word', () => { t.describe('words', (t) => { t.it('noArgs') - .it('with count = 10', 10) - .it('with count = 20', 20) - .it('with options.count', { count: 10 }) + .it('with count = 4', 4) + .it('with options.count', { count: 4 }) .it('with options.count range', { count: { min: 18, max: 20 } }); }); }); @@ -63,13 +61,13 @@ describe('word', () => { expect(result).toEqual(['foo', 'bar', 'baz', 'a']); }); - it('returns the word list if no words match the length', () => { - const result = filterWordListByLength({ - wordList, - length, - }); - // TODO @ST-DDT 2022-10-02: This should throw an error in the next major version. - expect(result).toEqual(wordList); + it('by default throws an error when no words match the given length', () => { + expect(() => { + filterWordListByLength({ + wordList, + length, + }); + }).toThrow('No words found that match the given length.'); }); it('returns the appropriate words when strategy is "any-length" and no words match the given length', () => { |
