diff options
| author | Jason Papakostas <[email protected]> | 2022-03-28 09:52:27 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-03-28 16:52:27 +0000 |
| commit | 5ed963f1e4928eb2df36f230faf7f9d63b51bef1 (patch) | |
| tree | 00f5a2ba8cf2e3219454f3859041f3c76ea3339a /test | |
| parent | 9fad09a71c1579009cb94b79e003c437a22f43a5 (diff) | |
| download | faker-5ed963f1e4928eb2df36f230faf7f9d63b51bef1.tar.xz faker-5ed963f1e4928eb2df36f230faf7f9d63b51bef1.zip | |
fix: force passed locales into faker constructor (#580)
Co-authored-by: Shinigami92 <[email protected]>
Diffstat (limited to 'test')
| -rw-r--r-- | test/faker.spec.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/faker.spec.ts b/test/faker.spec.ts index 54fa04ac..283cf999 100644 --- a/test/faker.spec.ts +++ b/test/faker.spec.ts @@ -1,11 +1,33 @@ import { beforeEach, describe, expect, it } from 'vitest'; -import { faker } from '../src'; +import { faker, Faker } from '../src'; describe('faker', () => { beforeEach(() => { faker.locale = 'en'; }); + it('should throw error if no options passed', () => { + expect( + () => + // @ts-expect-error: mission options + new Faker() + ).toThrow( + Error('Options with at least one entry in locales must be provided') + ); + }); + + it('should throw error if no locales passed', () => { + expect( + () => + // @ts-expect-error: missing locales + new Faker({}) + ).toThrow( + Error( + 'At least one entry in locales must be provided in the locales parameter' + ) + ); + }); + // This is only here for coverage // The actual test is in mersenne.spec.ts describe('seed()', () => { |
