|
|
@@ -224,6 +224,8 @@ describe('LocaleRuntime', () => {
|
|
|
.toThrow('already registered')
|
|
|
expect(() => svc.addLanguage({ id: 'bad locale', label: 'Bad', fallback: 'en' }))
|
|
|
.toThrow('not a BCP 47-style tag')
|
|
|
+ expect(() => svc.addLanguage({ id: '123', label: 'Numeric', fallback: 'en' }))
|
|
|
+ .toThrow('not a BCP 47-style tag')
|
|
|
expect(() => svc.addLanguage({ id: 'fr', label: ' ', fallback: 'en' }))
|
|
|
.toThrow('label must not be empty')
|
|
|
expect(() => svc.addLanguage({ id: 'fr', label: 'Français', fallback: 'bad tag' }))
|
|
|
@@ -232,6 +234,15 @@ describe('LocaleRuntime', () => {
|
|
|
.toThrow('not registered')
|
|
|
})
|
|
|
|
|
|
+ it('rejects malformed locale ids before dictionary registration', () => {
|
|
|
+ const { svc } = make()
|
|
|
+ expect(() => svc.register('ns', 'bad locale', { hello: 'Bad' }))
|
|
|
+ .toThrow('not a BCP 47-style tag')
|
|
|
+ expect(() => svc.register('ns', '123', { hello: 'Numeric' }))
|
|
|
+ .toThrow('not a BCP 47-style tag')
|
|
|
+ expect(svc.bind('ns')('hello')).toBe('hello')
|
|
|
+ })
|
|
|
+
|
|
|
it('walks each language fallback recursively for every dictionary key', () => {
|
|
|
const { svc } = make()
|
|
|
svc.register('ns', 'en', { base: 'English', shared: 'English shared' })
|