From 5ea8252f727e2e577c2adca9650ac8f24a171632 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Tue, 14 Jun 2022 14:18:50 +0200 Subject: feat: throw error on unknown locale (#1071) --- test/faker.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') 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 = Object.keys(console) .filter((key) => typeof console[key] === 'function') -- cgit v1.2.3