diff options
| author | Shinigami <[email protected]> | 2022-06-14 14:18:50 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-14 14:18:50 +0200 |
| commit | 5ea8252f727e2e577c2adca9650ac8f24a171632 (patch) | |
| tree | ebc4c226c2ac2d126a6e84bc43aded4d2cca2862 /test | |
| parent | e8985f60074969393fd57fc9f4f7d747742bc87c (diff) | |
| download | faker-5ea8252f727e2e577c2adca9650ac8f24a171632.tar.xz faker-5ea8252f727e2e577c2adca9650ac8f24a171632.zip | |
feat: throw error on unknown locale (#1071)
Diffstat (limited to 'test')
| -rw-r--r-- | test/faker.spec.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/faker.spec.ts b/test/faker.spec.ts index 013f7a4e..0d25813b 100644 --- a/test/faker.spec.ts +++ b/test/faker.spec.ts @@ -32,6 +32,24 @@ describe('faker', () => { ); }); + it('should throw error if locale is not known', () => { + const instance = new Faker({ locales: { en: { title: 'English' } } }); + expect(() => (instance.locale = 'unknown')).toThrow( + new FakerError( + 'Locale unknown is not supported. You might want to add the requested locale first to `faker.locales`.' + ) + ); + }); + + it('should throw error if localeFallback is not known', () => { + const instance = new Faker({ locales: { en: { title: 'English' } } }); + expect(() => (instance.localeFallback = 'unknown')).toThrow( + new FakerError( + 'Locale unknown is not supported. You might want to add the requested locale first to `faker.locales`.' + ) + ); + }); + it('should not log anything on startup', () => { const spies: Array<SpyInstance> = Object.keys(console) .filter((key) => typeof console[key] === 'function') |
